Reputation: 315
I am trying to run this function with the following user input structure but cannot get a correct answer:
def biggest_number(*args):
print (max(args))
return max(args)
a = (int(x) for x in input().split())
# 3,4,5
print (biggest_number(a))
So far I have tried different type of brackets "(" for tuples and "[" for lists as well as tried converting the strings to integers.
Upvotes: 1
Views: 82
Reputation: 78554
You can unpack the generator expression using the splat operator:
print (biggest_number(*a))
Although I think you actually want to use a container such as tuple or list since you can only consume the gen. exp. once so that the next call to max
after the print gives you an error:
a = [int(x) for x in input().split()]
Or:
a = tuple(int(x) for x in input().split())
However, you still need to unpack since your function does not take the iterables directly.
Upvotes: 1