Is there any way to generate a number of raw_inputs (With unique variables) based on user input? So, say I had this:
if choice == 1:
noelemen = int(raw_input("Enter total amount of elements: "))
Would there be any way to make it so the integer put in that raw_input field would then "generate" the required amount of raw_inputs? I'd suppose, if it was possible, that it'd make use of functions or something similar, but I'm a bit confused about how I'd get it done to be able to do that.
What I have currently is this:
if noelemen == 1:
first = raw_input("Enter element: ")
#Look for the weight of the entered element
weight1 = float(elemen_data.get(first.lower()))
if weight1 is not None:
total_weight = weight1
print "Total mass =", total_weight
if noelemen == 2:
first = raw_input("Enter first element: ")
second = raw_input("Enter second element: ")
#Look for the weight of the entered element
weight1 = float(elemen_data.get(first.lower()))
weight2 = float(elemen_data.get(second.lower()))
if weight1 is not None:
total_weight = weight1 + weight2
print "Total mass =", total_weight
Which is probably a pretty messy way of doing it, particularly as I'd have to go up to perhaps something like 10 elements, or perhaps even beyond.
So, to repeat... Any way to generate raw_inputs with unique variables based on user input?