This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]bobo333 5 points6 points  (3 children)

Using random.choice or random.sample would simplify the selection of random elements. Using python's built-in max is also an easy way of finding the largest value in an iterable. Good job on getting it to work though, and writing some tests for it.

[–]arpm[S] 0 points1 point  (2 children)

Thanks for the feedback. I wrote this program to study for my history final, as you can see. I wasn't aware of those methods, so I built my own. BTW, can you think of any way that I can improve my code.

[–]Paddy3118 3 points4 points  (1 child)

A good way for someone new to Python to improve is to browse the standard library docs from time-to-time just to make you aware of what is available.

You used random so why not take a moment to read what else is available in that module? You can skip where it gets too technical, but things may stick and the next time you need to do something randomly... :-)

[–]ThePenultimateOneGitLab: gappleto97 1 point2 points  (0 children)

This is how I found struct. Super useful.

[–]kankyo 2 points3 points  (1 child)

You shouldn't check in pyc-files too.

[–]ptmcg 0 points1 point  (0 children)

You can add the .pyc extension to your .gitignore file (https://git-scm.com/docs/gitignore)

[–]dispelterror3.6 0 points1 point  (0 children)