2

My function read(one,two,three) takes 3 inputs.

I have a tuple of tuples and I want to apply the function on the tuples inside, e.g.:

a = ((1,2,3), (2,3,4), (3,4,5))
for i in (a):
  read(i)

I'd expect it to do read(1,2,3) in the first loop, but it's returning TypeError because it's reading (1,2,3) as one parameter. How should I fix this problem? Thank you!

quickhelp
  • 99
  • 6

1 Answers1

3

Unpack the elements using *

Ex:

a = ((1,2,3), (2,3,4), (3,4,5))
for i in (a):
  read(*i)
Rakesh
  • 81,458
  • 17
  • 76
  • 113