I am attempting to clear lines of code in Python and came across a post at Any way to clear python's IDLE window? on how to do so however when I run the function below in IDLE 3.3 I get the error below. It does however work in version 2.7.3.
ERROR
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
cls()
File "<pyshell#6>", line 2, in cls
print('\n') * 100
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
CODE
def cls():
print('\n') * 100
You probably mean
When you multiply a string by an int, it is repeated:
But what you do is multiply the value of
print('\n')by100. Butprint()doesn’t return anything (read: returnsNone), hence the error: you can’t multiplyNoneandint.In Python 2 there is no difference, because there are no parentheses:
Still, it’s interpreted by Python the same way as in Python 3 (and not the same way you seem to iterpret it).