def menuAdiciona():
nome = input("Digite o nome de quem fez o cafe: ")
nota = int(input("Que nota recebeu: "))
if len(str(nome).strip()) == 0:
menuAdiciona()
if (nota) == 0:
menuAdiciona()
if nota < 0:
nota = 0
appears this:
Can't convert 'int' object to str implicitly
First, the code you provided "works" in Python 2.7 and 3.
A line number or stacktrace would be helpful, but assuming it's in the snippet you provided:
nota = int(input("Que nota recebeu: "))
Here nota
is an int.
if len(str(nome).strip()) == 0:
The next line you're trying to cast it to a string without specifying how.
Something like:
if len(("%d" % nota).strip()) == 0:
should prevent the error.
That being said, the line still makes little sense. You shouldn't have to strip()
a string representation of an integer.
What are you trying to accomplish with strip()
and the if len(...) == 0
parts?
Edit: Lastly, I think you want raw_input()
instead of input()
, unless you're shadowing that somewhere too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.