Page 1 of 1

Write a program which prompts the user to enter a dictionary. Use the eval() function to read a dictionary literal from

Posted: Mon May 02, 2022 12:06 pm
by answerhappygod
Write A Program Which Prompts The User To Enter A Dictionary Use The Eval Function To Read A Dictionary Literal From 1
Write A Program Which Prompts The User To Enter A Dictionary Use The Eval Function To Read A Dictionary Literal From 1 (59.16 KiB) Viewed 27 times
Write a program which prompts the user to enter a dictionary. Use the eval() function to read a dictionary literal from the user {key:value, ...} then use it to create and print a list of tuples. Each tuple in the list should be of the form (key,value) for each key in the dictionary with associated value. Example: if the user enters {1:"one", 2:"two",47:"forty-seven"}, you should create the list [(1,"one"),(2,"two"), (47,"forty-seven")]then print it out. Hint: use the accumulator pattern to build your list.