i keep getting a TypeError: Can't convert 'NoneType' object to str implicitly on the 6th line of code [duplicate]
Clash Royale CLAN TAG#URR8PPP
i keep getting a TypeError: Can't convert 'NoneType' object to str implicitly on the 6th line of code [duplicate]
This question already has an answer here:
help me with this im new to coding im trying a one of the lessons in "Automate the boring stuff with python" the code goes as follows.
# this program says hello and asks for my name.
print('hello world!')
print('what is your name?') # ask for their name
myName = input()
myName = print()
print('it is good to meet you,' + myName)
print('the length of your name is:')
print(len(myName))
print('what is your age?') # ask for their age
myAge = print()
print('you will be ' + str(int(myAge) + 1) + ' in a year. ')
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
myAge = print()
print
None
input()
There is nothing at line 6.
– Christian Dean
Oct 4 '16 at 19:32
1 Answer
1
Your error seems to be in
myAge = print()
print is giving info to stdout, not sending info in. The print method expects at least one parameter of a string to print. To print your variable 'myAge' simply:
print(myAge)
His error it that you cannot print variable in Python like this
myName = print()
, and because of that he's getting NonType error.– Tuc3k
Oct 4 '16 at 18:45
myName = print()
myAge = print()
.print
returnsNone
. What are you trying to do there? Is that supposed to beinput()
?– Morgan Thrapp
Oct 4 '16 at 18:29