Hello guys I have this list from json post: The Json:
{"Array":"[(1, 2), (1, 3), (2, 3), (3, 4), (3, 5), (4, 5), (4, 6), (5, 6), (6, 7)]"}
I need to transform it in this format:
type<class 'list'>
[(1, 2), (1, 3), (2, 3), (3, 4), (3, 5), (4, 5), (4, 6), (5, 6), (6, 7)]
What i have tried:
def getData():
json_data = request.get_json()
newList=[]
[newList.extend([v]) for k,v in json_data.items()]
print("type:",type(newList))
# OUTPUT: <class 'list'>
print("list:",newList)
# OUTPUT:['[(1, 2), (1, 3), (2, 3), (3, 4), (3, 5), (4, 5), (4, 6), (5, 6), (6, 7)]']
print("type 1:",type(newList[0]))
# OUTPUT:<class 'str'>
print("list 1 :",newList[0])
# OUTPUT:[(1, 2), (1, 3), (2, 3), (3, 4), (3, 5), (4, 5), (4, 6), (5, 6), (6, 7)]
In the first its a list but not in the format that i need, in the second its not a list but its in the format that i need.
Thanks for help!