![Athenax](/avatars/47703.jpg)
Athenax
07.01.2021 •
Computers and Technology
How to format each dictionary item as a text string in the input file. How to covert each input string into a dictionary item. How to format each item of your inverted dictionary as a text string in the output file.
Solved
Show answers
More tips
- F Food and Cooking 10 Reasons Why You Should Avoid Giving Re-Gifts: An Informative Guide...
- F Family and Home How to Sew Curtain Tapes: Best Tips from Professionals...
- A Animals and plants How to Grow Lime from a Seed: Simple Tips and Interesting Facts...
- C Computers and Internet How to Create a Folder on Your iPhone?...
- G Goods and services How to sew a ribbon: Tips for beginners...
- F Food and Cooking How to Make Mayonnaise at Home? Secrets of Homemade Mayonnaise...
- C Computers and Internet Which Phone is Best for Internet Surfing?...
- F Food and Cooking Everything You Need to Know About Pasta...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
Answers on questions: Computers and Technology
- S Social Studies What does TVET stands for?...
- M Mathematics Use the following x-values (0, 1, 2, 3) to find ordered pairs for this equation: y = 2x - 3...
- P Physics Arailroad track is being built on an inclined surface. what is the estimated height of the supporting pillar that will be erected at a horizontal distance of 200 meters from...
- M Mathematics Acrop scientist is conducting research with a drought resistant corn hybrid. she is interested in determining if using fertilizer x will increase plant height. she prepares...
Ответ:
- To get the items of a dictionary and print them as a string, use the items() method to unpack the keys and values in a for and print or write them into a file.
for key, value in mydict.items():
print(f"{key}, {value}")
- To convert string from user input into dictionary;
mystring = input().split(" ") #assuming the words are separated by a space.
from word in mystring:
mydict[word] = mydict.get(word, 0) + 1
This would use the words in the string as the keys of the dictionary and the count of each word as the respective values.
Explanation:
A dictionary is a data structure in python used to store data in key-value pairs. The items are enclosed in curly braces and can be accessed with the key in dot or bracket notation.
Ответ:
drip dirp
Explanation: