These two codes have only one difference in them.
The first one has a *
in it and the second one dosen't.
The first code runs properly and the second code gives this error:
TypeError: argument should be a string or a Rational instance
Code 1: The correct code.
from fractions import Fraction
fracs = []
for _ in range(int(input())):
fracs.append(Fraction(*map(int, input().split())))
print(fracs)
Code2 : The errorneous code.
from fractions import Fraction
fracs = []
for _ in range(int(input())):
fracs.append(Fraction(map(int, input().split())))
print(fracs)
I had learn python from Multiple sites like 'GeeksForGeeks' and 'Tutorial Point'. I checked and they don't tell what does this *
does apart from being used as a multiplier,string-repeater and passing multiple argument.
Link to the page: https://www.tutorialspoint.com/What-does-the-Star-operator-mean-in-Python
Also, searched for this in stackoverrflow's previously asked question but it doesn't give any satisfying result.
Thanks in advance.