I´m new to python and uses the latest version of 3.7 on mac 64bit. When put in following code and run model, my name don´t show: " Its good to meet you, (blank)!"
What is wrong?
print('Hello World')
print('Whats your name?')
myname = input ('Alexander')
print('Its good to meet You,' + myname +'!')
The input function expects user input while the function is running, eg input()
and then you would type your name in the terminal. "Alexander" should be shown in the terminal with your current code. Try
print('Hello World')
myname = input('Whats your name?')
print('Its good to meet You,' + myname +'!')
Then type "Alexander" in the command prompt
The input function is used to let the user inputs string after the start. You have to type something when it sais alexandre
it seems you put a space after input function. instead of
print('Whats your name?')
myname = input ('Alexander')
Try this
myname = input("Whats your name? ")
and after running this code when this ask for name just type in your name
the comple code will look like this
print('Hello World')
myname = input("Whats your name? ")
print('Its good to meet You, {} !'.format(myname))
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.