edualgo / eduAlgo

A simple python package having modules of different algorithms to use in educational purposes.
https://edualgo.github.io/documentation/
MIT License
99 stars 54 forks source link

Consider using `mapp.items()` to iterate over the dictionary #193

Closed VenkatsQuest closed 2 years ago

VenkatsQuest commented 2 years ago

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)

Abhijit2505 commented 2 years ago

@VenkatsQuest please get started.

VenkatsQuest commented 2 years ago

@Abhijit2505 its already fixed as part of one of the recent pull request.