Answers for "python tupel from string"

0

python tupel from string

from ast import literal_eval as make_tuple

food_tuple_str = "('pizza', 'pasta', 'fish')"
food_tuple = make_tuple(food_tuple_str)
print(food_tuple)  # ('pizza', 'pasta', 'fish')
print(type(food_tuple))  # <class 'tuple'>
Posted by: Guest on October-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language