I am trying to convert this tuple into a list, however when I run this code:
mytuple=('7578',), ('6052',), ('8976',), ('9946',)
List=[]
for i in mytuple:
Start,Mid,End = map(str, mytuple.split("'"))
List.append(Mid)
print(List)
I receive this error:
AttributeError: 'tuple' object has no attribute 'split'
The output should be:
[7578, 6052, 8976, 9946]
this is what you are looking for
mytuple = (('7578',), ('6052',), ('8976',), ('9946',))
result = [int(x) for x, in mytuple]
print(result)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With