'How to make my code read more than one digit at a time? One digit input works but two-digit or more inputs does not work [closed]
I am a beginner in Python. My code works for one-digit numbers but not two-digit. I know the for-loop is reading user input one digit at a time but I have no idea how to make it read my input like it would in an array. Ex. 5,7,9 is read as 5,7,9 but 5,70, 9 is read 5, 7, 9.
largest = None
smallest = None
while True:
try:
num = input("Enter a number: ")
num1 = float(num)
except:
if "done" == num:
break
print("Invalid input")
continue
for value in num:
if smallest is None:
smallest = num
if num < smallest:
smallest = num
#print(smallest, num)
elif largest is None:
largest = num
if num > largest:
largest = num
#print("Maximumcc is:", largest)
print("Maximum is:", largest)
print("Minimum is: ", smallest)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
