Write a program which prompts the user to enter a dictionary. Use the eval() function to read a dictionary literal from
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Write a program which prompts the user to enter a dictionary. Use the eval() function to read a dictionary literal from
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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!