+ 1
Can you put more numbers in a int(input())
3 Réponses
+ 2
Something like this?
(Give multiple numbers separated by space.)
for example,
INPUT: 5 2 8 4 3
OUTPUT: the largest number is 8
[CODE]
Largest_so_far = 0
print("""choose numbers above 0 for which you want to know which is the largest.
Separate numbers with,
""")
for the_num in [int(i) for i in input().split()]:
if the_num > Largest_so_far:
Largest_so_far = the_num
print(Largest_so_far, the_num)
print('this is the Largest number', Largest_so_far)
+ 5
Dico , here some thoughts about a possible solution:
▪︎getting the input as int numbers in a list could be done like:
nums_list = [int(i) for i in input().split()] # input like: 4 23 0 43 11 (separated by space)
▪︎when you have got the input numbers in the list, you can get the largest number by using max()
print(max(nums_list))
+ 2
Thanks a lot