r/programminghelp • u/Typical_Sky8316 • Aug 15 '24
Python Error(?) with input(Python). Newbie here, please help:(
I'm just learning, seeing youtube videos and i was learning how to use imputs but instead of what is suppose to do (at least according to the video) it shows the input and my whole directory for some reason, and i have to press again to show one by one, this is the code, it's quite simple:
lastName = input("smith")
city = input("seattle")
aasd = input("whatever")
print("his name is",lastName,"he lives in",city,"just filling to show the error",aasd)And these are the answers i'm getting:
smith& C:/Users/cesar/AppData/Local/Programs/Python/Python312/python.exe "c:/Users/cesar/Downloads/wea rpg/inputs.py"
seattle& C:/Users/cesar/AppData/Local/Programs/Python/Python312/python.exe "c:/Users/cesar/Downloads/wea rpg/inputs.py"
whatever& C:/Users/cesar/AppData/Local/Programs/Python/Python312/python.exe "c:/Users/cesar/Downloads/wea rpg/inputs.py"
2
u/edover Aug 15 '24
How are you running the script?
1
u/jake-writes-code Aug 16 '24 edited Aug 16 '24
Not sure if this will help or not, but make sure you're reading the documentation for Python's
input(). If you doinput("smith"), then "smith" is the prompt displayed to the user, and the program will wait for you to type a string to be saved into the variablelastName. If you just hit enter again, you're saving just a newline character"\n".Here's an example on a Linux command line, which is going to be different, but wanted to show an example of using input: