Consider using `mapp.items()` to iterate over the dictionary
VenkatsQuest opened this issue · comments
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
The preferred way to iterate over the key-value pairs of a dictionary is to declare two variables in a for loop, and then call dictionary.items() (or dictionary.iteritems() for Python2), where dictionary is the name of your variable representing a dictionary.'
Describe the solution you'd like
A clear and concise description of what you want to happen.
edualgo/algorithms/string_algorithms.py
for key in mapp.keys():
406 output = output + key + str(mapp[key])
should be replaced with
for key, value in mapp.items():
output = output + key + str(value)
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Examples
Not preferred
details = {"first_name": "Alfred", "last_name":"Hitchcock"}
for key in details.keys():
print(key, d[key])
Preferred
details = {"first_name": "Alfred", "last_name":"Hitchcock"}
for key, value in details.items():
print(key, value)
@VenkatsQuest please get started.
@Abhijit2505 its already fixed as part of one of the recent pull request.