how to stop the code without quitting python with the code given. I tried "stop" and I think it worked 5 hours ago, but now it doesn't.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 7PP
icon
Related questions
Question

how to stop the code without quitting python with the code given. I tried "stop" and I think it worked 5 hours ago, but now it doesn't.

#Initial list
x = [1,3,6,7]
#creating an input statement
num=input('Insert a number between 1 to 100: ')
#checking if the user inputs an integer or a string
-if num.isdigit():
num = int(num)
-else:
print (f"ERROR: You entered something that is not an integer. Your input was: {num}.\nPlease enter a number again.\n")
num=input('Please enter a number again between 1 to 100: ')
#second try for the user to enter an integer
if num.isdigit():
num = int(num)
else:
print (f"ERROR: You entered something that is not an integer. Your input was: {num}. Please restart the program.")
######################### STOPPING THE CODE HERE #################################
#checking if the input is between 1 to 100
∙if (num >= 1) and (num <= 100):
print (f'The original list is given as: {x}')
x.append(num)
print (f'The updated list is given as: {x}\n')
x1 = set (x)
print (f'The converted list to set is given as: {x}')
#Variables to store the length of the list and set
length_x = len(x)
length_x1 = len(x1)
#if statement to check if length of set and list is the same.
if length_x == length_x1:
print (f'The set length is the same as the list length. The value of set is: {length_x1} and the value of list is: {length_x}')
print (f'The set length is not the same as the list length. The value of set is: {length_x1} and the value of list is: {length_x}')
print (f'ERROR: You entered a number not between 1 to 100. Your number was: {num}. Please try again by restarting the program.')
else:
else:
Transcribed Image Text:#Initial list x = [1,3,6,7] #creating an input statement num=input('Insert a number between 1 to 100: ') #checking if the user inputs an integer or a string -if num.isdigit(): num = int(num) -else: print (f"ERROR: You entered something that is not an integer. Your input was: {num}.\nPlease enter a number again.\n") num=input('Please enter a number again between 1 to 100: ') #second try for the user to enter an integer if num.isdigit(): num = int(num) else: print (f"ERROR: You entered something that is not an integer. Your input was: {num}. Please restart the program.") ######################### STOPPING THE CODE HERE ################################# #checking if the input is between 1 to 100 ∙if (num >= 1) and (num <= 100): print (f'The original list is given as: {x}') x.append(num) print (f'The updated list is given as: {x}\n') x1 = set (x) print (f'The converted list to set is given as: {x}') #Variables to store the length of the list and set length_x = len(x) length_x1 = len(x1) #if statement to check if length of set and list is the same. if length_x == length_x1: print (f'The set length is the same as the list length. The value of set is: {length_x1} and the value of list is: {length_x}') print (f'The set length is not the same as the list length. The value of set is: {length_x1} and the value of list is: {length_x}') print (f'ERROR: You entered a number not between 1 to 100. Your number was: {num}. Please try again by restarting the program.') else: else:
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage