+ 2

Can anybody help me to correct my code please?

You just need to take three numbers as input from stdin and you need to find greatest of them. Please correct me with the below code. def main(): a,b,c = input(), input(), input() print(max(a,b,c),end") main()

31st Oct 2019, 7:37 AM
Manju Gurung
Manju Gurung - avatar
3 odpowiedzi
31st Oct 2019, 7:54 AM
estifanos
estifanos - avatar
+ 4
here an other approach, without having a fixed number of input values: # input with a comprehension: you are not having a restriction to a fixed number of input values!! # input is taken by n numbers, separated by comma. input is split, converted to int and then appended to the list. lst = [int(i) for i in (input('n numbers sep. by comma: ').split(','))] print(max(lst)) # or if list is not needed for further purpose: print(max([int(i) for i in (input('n numbers sep. by comma: ').split(','))]))
31st Oct 2019, 10:23 AM
Lothar
Lothar - avatar
+ 2
def main(): a, b, c = (int(input()) for _ in range(3)) print(max(a, b, c), end='') main()
31st Oct 2019, 10:08 AM
Asman-H
Asman-H - avatar