+ 2
How can i ask input from the user in Python?
19 Réponses
+ 5
By just copying the link to the code and adding it to your message, the code will be attached to your post. d:
For the actual code itself, to get x and y to have a value specified by the user can be done by doing the following:
x = int(input())
y = int(input())
This asks the user to enter a value, then it stores the value in the variable. To enter multiple values when prompted, just add the second value on a separate line, and it should be stored into the second variable.
Hope this helped! d:
+ 4
Yes it works just fine as @Faisal describes -
+ 4
the one thing i personally don't like is when the window opens to input it does tell you how many integers to input or if it's a series of strings or an array
+ 4
when you input x click the ↩ dropdown key or next line button on your keypad. ( shift key )
+ 4
you should be able to:
50↩
100 "GO ▶" assigning y as 100
I also did:
100↩
50 "GO ▶" assigning x as 100
+ 3
Ulhas Bharadwaj Are you able to show me the code that you're referring to?
+ 3
This should be the one you're referring to ---> https://code.sololearn.com/cmpSJe9XmbOd/?ref=app
+ 3
Thank you so much, Faisal :)
+ 3
You will learn many things here young grasshopper - LOL
When you snatch this cricket from my hand you will become the master and be free to leave :)
Okay, I got a little Kung Fu flashback... But you got the picture right? ! ?
+ 2
To do so, you can simply just assign a variable to a value of the function input() which prompts the user to enter something and converts it to a string. To change what is entered to an int can be done by surrounding the input() function with the int() function, converting the value the user entered to an integer.
+ 2
I don't get how to ask for input in the code. When I run someone else's program, it clearly asks me to give an input. I don't know what word to use there. It might sound silly. but I'm pretty new to this...
+ 2
yes
+ 2
thing is, i want to ask the user for the values of x and y
+ 2
idk why, but i'm getting an error when I give the user to choose his input. when only x input can be varied according to the user, the there is no problem, but the problem arises when i do the same to y
+ 2
I'll try it
+ 2
Ok, i get it now. I never knew you could give 2 inputs at one go... Thank you so much, Robert :)
+ 2
yea :)
+ 1
I've made it public, but is there a way through which I can directly link it here?
+ 1
I'm getting an EOF error for line 2