I am new to Python, I have a book entitled 'Automate the Boring Stuff' by Al Sweigart. I am going through it.
Why is myName = input() not working? I thought input() should assign the string mike to myName.
The code is copied directly from the book, which was published in 2015. Python probably has not changed so much since then.
When I change to
This is the output in a bash terminal. I am using Ubuntu 16.04
Why is myName = input() not working? I thought input() should assign the string mike to myName.
The code is copied directly from the book, which was published in 2015. Python probably has not changed so much since then.
When I change to
Quote:myName = raw_input()it works fine.
This is the output in a bash terminal. I am using Ubuntu 16.04
Quote:Hello world!
What is your name?
mike
Traceback (most recent call last):
File "enteraVariableAndPrintIt.py", line 5, in <module>
myName = input()
File "<string>", line 1, in <module>
NameError: name 'mike' is not defined
------------------
(program exited with code: 1)
Press return to continue
# This program says hello and asks for my name. print('Hello world!') print('What is your name?') # ask for their name myName = input() 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 = input() print('You will be ' + str(int(myAge) + 1) + ' in a year.')Thanks for any tips.