Python - Save user inputs in new variables -
this question has reply here:
how do variable variables in python? 8 answersi want save multiple inputs. if user of programme wants loop 100 times want programme save 100 diffrent variables n1,n2,3 , on.
first round:
while true: n1 = input("what number? (done quit) ") if n1 == 'done': break print(n1) print(n2) , on..
second round:
while true: n2 = input("what number? (done quit) ") if n2 == 'done': break print(n1) print(n2) , on..
is possible in python3? have googled alot , can´t find it! :/
regards
you can do:
results = {} counter = 1 while true: response = input("what number? (done quit) ") if response == 'done': break results[counter] = response counter += 1
you can print results:
print(results.items())
you can break depending on counter value (within loop):
if counter == 100: break
python variables python-3.x input
No comments:
Post a Comment