Questions about tuple-list conversion

Asked 2 years ago, Updated 2 years ago, 102 views

I solved the problem of changing interest = ('Samsung Electronics', 'LG Electronics', 'SK Hynix') to list type with interest = ['Samsung Electronics', 'LG Electronics', 'SK Hynix'] and the answer was data = list (interrest). However, if you proceed according to the answer, it will still come out as a tuple when you print out the type. What's the problem?

tuple

2022-09-20 15:38

1 Answers

No way. It's going to say list.

interest=('Samsung Electronics', 'LG Electronics', 'SK Hynix')
data = list(interest)

print(type(interest) # Of course, this comes out as <class 'tuple'>
print(type(data)) # But this one comes out well as <class 'list'>


2022-09-20 15:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.