Reputation: 11
largest = None
smallest = None
while True:
num = raw_input("Enter a number: ")
if num == "done" : break
try:
halo = float(num)
except:
print("invalid output")
continue
for largest in range(halo):
if largest is None:
largest = halo
elif largest > halo:
largest = halo
for smallest in range(halo):
if smallest is None:
smallest = halo
elif smallest<halo:
smallest = halo
print("largest is",largest)
print("smallest is",smallest)
i want to print smallest and largest number but im getting a error "start must be an integer on line 11" i know there will be some other mistake in my code but i want to correct this first
Upvotes: 0
Views: 573
Reputation: 90899
The arguments to range
function should be plain integer documentation
You should convert to int
instead of float
-
halo = int(num)
Upvotes: 1