ed-lau / python-for-everybody

Class notes
213 stars 242 forks source link

issue in break #1

Open sagunraul opened 4 years ago

sagunraul commented 4 years ago

I am getting issue in break in line no.5 please help me

largest = None smallest = None while True: num = raw_input("Enter a number: ") if num == "done" :break

try: num = int(num) except: print ("Invalid input") continue

if largest is None: largest = num elif largest < num: largest = num

if smallest is None: smallest = num elif smallest > num: smallest = num

print ("Maximum is", largest) print ("Minimum is", smallest)

ZekeLandon commented 4 years ago

Hi @sagunraul,

Can you paste your code using Insert Code option so that it becomes easy to tell what's wrong Also, mention what's your error

Regards, Zeke

SHIVANI0708 commented 4 years ago

Hi @sagunraul I have got the problem so can you please tell me how can I tell That to you??

muduliratikant commented 1 year ago

Hi @sagunraul I have got the problem so can you please tell me how can I tell That to you??

largest = None smallest = None

while True: num_input = input("Enter a number: ") if num_input == "done": break try: num = int(num_input) if largest is None or num > largest: largest = num if smallest is None or num < smallest: smallest = num except ValueError: print("Invalid input")

if largest is not None and smallest is not None: print("Maximum is", largest) print("Minimum is", smallest)