-2
I have the following code:
quantidade = int(input("Quantos episódios? "))
inicio = 1
numero_do_post = 379
numero_do_anime = 6
arquivo = open("script.txt", "w")
while (inicio <= quantidade):
arquivo.write(numero_do_anime)
inicio = inicio + 1
arquivo.close()
When I print the variable it gives the following error:
Traceback (most recent call last):
File ".\script.py", line 11, in <module>
arquivo.write(numero_do_anime)
TypeError: write() argument must be str, not int
I want him to come out a number in a row: 6,7,8 etc... do not understand the mistake.
The problem is not in the
inicio = inicio + 1
, but in thearquivo.write
. The error message is saying: the functionwrite
accepted only string as parameter and you are passing an integer.– Woss
So how can I write the number in the text, so that in the next loop it gets itself + 1?
– Sandson Costa
What exactly do you want to do? If you just fix the question error you will write in your file several times the number 379. For example, if the user typed 100 in his file they would have 100 times the number 379. It doesn’t seem like that’s what you want, so just solving the problem wouldn’t be enough. Could you describe in detail what you are trying to do and what output you want?
– Woss