code, programming, python

Python Code Using Marvel Comics – Part 4

The python coding adventure continues. I was making great progress until I hit another roadblock. How do you take a list of strings and associate a numerical value to them? What’s more, how do you perform a calculation based on those values many of which have duplicates?

The answer was a combination of dictionaries and tuples. Essentially, I made a dictionary of the keys and associated values and then did a lookup based on the dictionary. I then converted my list into a dictionary and subsequently a tuple. From there, I was able to create a loop with a basic IF ELSE lookup that associated a key to the value pair and whammo. I had gotten past the next stage. Current code line count is at 331 lines.

Next up, will be taking on powers. For that it will be using a combination of random.choices with the powers function.

The current code is on my GitHub, Replit, and Trinket.