Ask Question
1 February, 02:55

Write a loop to populate user_guesses with num_guesses integers. read integers using int (input ()). ex: if num_guesses is 3 and user enters 9 5 2, then user_guesses is [9, 5, 2].

+1
Answers (1)
  1. 1 February, 04:19
    0
    num_guesses = 3 #initialized number of guesses to 3

    user_guesses = [] #declared the user_guesses array

    guess = 0 #guess variable initialized to 0

    print ('Enter a number: ') #prompt telling the user to enter a number

    while guess < num_guesses: #loop capturing input and storing into array

    num = int (input ())

    user_guesses. append (num)

    guess = guess + 1

    #end of loop

    print (user_guesses) #array outputted to user

    Explanation:

    The above program captures numbers from the user and stores into an array (user_guesses), the length of the array is determined by the value contained in the num_guesses variable, it prints the combined input as an array.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a loop to populate user_guesses with num_guesses integers. read integers using int (input ()). ex: if num_guesses is 3 and user ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers