I have an assignment where I need to ask the user to input the total number of integers that will be in the data set, ask for each of the integers, and then add them into a list, then summarize the list into a dictionary.
For now I'm only worried about the user input part.
Here's what I have so far:
data = []
summary = {}
total_ints = int(raw_input('Total integers in data: '))
while total_ints:
each_int = int(raw_input('Enter an integer: '))
data.append(each_int)
Basically I need to only print the 'each_int' input based on the number the user enters in 'total_ints'. I know the while loop isn't correct, so any help would be greatly appreciated.
Thanks!
This is a loop whose body is executed total_ints times:
for i in range(total_ints):
data.append(int(raw_input('Enter an integer: ')))
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