anselmolsm
0
Q:

how to get a user input in python

input('ENter question here')
3
var = input("Text: ")
7
# creating an empty list 
lst = [] 
  
# number of elemetns as input 
n = int(input("Enter number of elements : ")) 
  
# iterating till the range 
for i in range(0, n): 
    ele = int(input()) 
  
    lst.append(ele) # adding the element 
      
print(lst) 
3
input = input("Enter your value: ") 

print(input) # prints the input
0
var = input("text: ")
1
a = input("what is your input")
1
while True:
    try:
        # Note: Python 2.x users should use raw_input, the equivalent of 3.x's input
        age = int(input("Please enter your age: "))
    except ValueError:
        print("Sorry, I didn't understand that.")
        #better try again... Return to the start of the loop
        continue
    else:
        #age was successfully parsed!
        #we're ready to exit the loop.
        break
if age >= 18: 
    print("You are able to vote in the United States!")
else:
    print("You are not able to vote in the United States.")
1
x = input("enter prompt here: ")
0
user = input("yes, no\n")
0

New to Communities?

Join the community