from math import gcd
nums = tuple(map(int,input().split()))
# find gcd of numbers in num
I tried the following code
print(gcd(nums))
but "TypeError: ‘tuple’ object cannot be interpreted as an integer" occures.
How can I solve this problem?
>Solution :
gcd takes an arbitrary number of positional args not an iterable, you need to unpack your tuple into positional args when you call it.
print(gcd(*nums))
NOTE: This was added in Python 3.9.
Changed in version 3.9: Added support for an arbitrary number of arguments. Formerly, only two arguments were supported.