while n == 1:
w = input("Input the product code: ")
Problem is that when a new code for w is entered, w is overwritten. For example, if w = 24, then w = 54, if you print(w) it will just print 54, since it's the latest input. How do you make it so that it prints all inputs for w?
Use a container type instead of a single variable. In this case, list() would seem appropriate:
inputs = [] # use a list to add each input value to
while n == 1:
inputs.append(input("Input the product code: ")) # each time the user inputs a string, added it to the inputs list
for i in inputs: # for each item in the inputs list
print(i) # print the item
Note: The above code will not compile. You need to fill in the value for the variable n.
inputs = []
for i in range(expected_number_of_inputs):
inputs.append(input('Product Code: '))
for i in inputs:
print(i)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With