I am using partition
in strings and am trying to use tuple
unpacking on them but it's returning the error expected 3 got 1
. So here's my code. Please explain where I went wrong.
a='aca'
for a,b,c in a.partition('c'):
print(a)
I am using partition
in strings and am trying to use tuple
unpacking on them but it's returning the error expected 3 got 1
. So here's my code. Please explain where I went wrong.
a='aca'
for a,b,c in a.partition('c'):
print(a)
You do not need a for loop for this, tuple unpacking is listed under the Tuples and Sequences section in the official Python documentation.
In [11]: A = 'aca'
In [12]: a, b, c = A.partition('c')
In [13]: a
Out[13]: 'a'
In [14]: b
Out[14]: 'c'
In [15]: c
Out[15]: 'a'