0

I am trying to create a list from user input but I need to find a way to ask how many integers the user wants, and take their answer to then ask them to enter an integer, depending on how many integers they want.

This is for my Computer Science homework and we are learning how to first use list and user input.

def numbers():
    list1 = []
    list_amount = int(input("How many integers would you like to add to the list? "))
    print("Enter an integer: ")
    for i in range(list_amount):
        print "Enter an integer: {}".format(list_amount)

I expect the output to look like this:

How many integers would you like to add to the list? 7
Enter an integer: 54
Enter an integer: 91
Enter an integer: 23
Enter an integer: 8
Enter an integer: -66
Enter an integer: 39
Enter an integer: 2
Loocid
  • 6,112
  • 1
  • 24
  • 42

0 Answers0