0
Simple Input/Output question (python beginner)
I want to run a program to understand a python intro lesson. the lesson proposes the following syntax: s = input("Enter something here") print(s) Something I get the first line printed because the only way I have to go to next line is by tapping the enter key on my phone. From then on, there's no way to run this program. please help.
17 Respostas
+ 8
oh, I believe you were using shell instead of IDLE..
when you open IDLE, you must press Ctrl+N to open a new window and write your code to execute.
then, you copy you code, save it, and press F5 to run the module
+ 8
@Chris, semicolon in Python???
+ 8
@Javier, python doesn't use ; at the end of the statements.
I'm not sure if I got your point, but to do anything with your variable and show the result you must use print statement.
s = input("enter something here")
print (s)
if s == "something":
print(yay!)
else:
print("oh no")
what your 3rd line should do?
+ 8
when you use "input" statement, the program waits some entry from the user. the rest of the code will be executed only after this entry. So, when you press enter, your input is actually an empty string like ""
+ 8
well, you must press enter. it's the trigger to Python understand that you're done and will go to the next line
+ 8
name = input("your name")
print (name)
output:
your name
Javier
you must create a variable and then store your input on it. then, you show your variable with its content
+ 8
I'll post your example on my code playground. take a look there and see if it's what you're looking for
+ 1
Thanks so much for helping me :) I should clarify the exercise works when following the exercise example. I'm trying to replicate on my comp.
I changed to notepad++ from Python IDLE and I now have no issue going into next line by pressing enter :)
I've typed the following:
s = print("name:")
print (s)
My name
now my challenge is how to run this. Hitting enter at the end doesn't yield anything :)
0
Thanks a lot Chris
0
@LayB, did not work... What should I do?
0
@LayB, the thing is that I can't go past line 1:
1 >>> s = input("enter something here").
For me to go to line 2, I don't know how to do so except by pressing enter on my keyboard after finishing the first line. This triggers the code in line one to be printed:
2 enter something here.
If I press enter again, I go back to:
3 >>>
So, I would just need to know how to be able to keep writing syntax from line 1 into line 2 without simply runing the code in line 1
0
I kind of figured something like that. Still, how to go into line 2 after input statement to keep correct syntax? I've tried \n, which yields an errror message.
when you type an input statement and you finish it, how do you go into the next line for output?
0
sorry, correction:
s = input("name:")
print (s)
My name
0
Thaaaanks :)
so, I tried the following:
input("your name: ")
Javier
Output is:
your name:
I get an error message: NameError, Javier is not a defined name
0
unfortunately I only get the input printed.
the output yields error: unexpected EOF while parsing.
Thanks so much. Don't worry, I'll look somewhere else also until I can get it done.
Tried to upvote all your answers, but what do you know? I seem to get an error too with that!
0
Yes, it worked fine. It works when I try it on the sololearn question interface as well. it's on pc where the output doesn't seem to show for one reason or another.
- 1
When using input you have to remember to use a semicolon at the end. First line should look similar to this:
s = input("Enter something");