Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello, please help me with the following code. It is written in Code Hs and is in python language. 5 points Status: Not Submitted Given
Hello, please help me with the following code. It is written in Code Hs and is in python language.
5 points Status: Not Submitted Given a list, have the user enter the same numbers and save the user input into a list. Display the list that the user entered. Compare the user's list to the correct list using a for loop to see if their elements are the same and in the same order. Hints: Typical alogrithm for comparing a list invloves assuming they are equal and then looking for one instance where the values are different. set a boolean to "true" loop through each index in a list Check to see if the value at the current index in one list is NOT equal to the value at the current index in the second list. if they aren't, then set the boolean to "false" After this algoritm is done, if the boolean is still true, then the lists are the same, if it is false, then the lists are different. Example Output: Please enter the following sequence: 4, 8, 15, 16, 23, 42 Value 1: 4 Value 2: 8 Value 3: 15 Value 4: 16 Value 5: 23 Value 6: 42 You entered: [4, 8, 15, 16, 23, 42] Good Job! The world has been saved! Please enter the following sequence: 4, 8, 15, 16, 23, 42 Value 1: 4 Value 2: 8 Value 3: 15 Value 4: 17 Value 5: 23 Value 6: 42 You entered: [4, 8, 15, 17, 23, 42] You entered them wrong! Watch out! O 8.3.9 Comparing Lists Save Submit + Continue 3 1 correctValues = [4, 8, 15, 16, 23, 42] 2 userValues = [] correct = True 4 5 print ("Please enter the following sequence: 4, 8, 15, 16, 23, 42") 6 print 7 8 # Get user Input 9- for i in range (len(correctValues)): val = int(input("Value" + str(i + 1) + ": ")) uservalues.append(val) print # Display user's input 10 11 12 13 14 15 16 17 18 19 20 # Check user's input # Display messageStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started