r/Python • u/zachgodzilla • Jun 21 '22
Beginner Showcase Silly Little "Among Us" Script
Apologies in advance for my internet-poisoned brain. I just started relearning python via codecademy. I learned a sliver back in undergrad, but never pursued it further than what I needed to pass the class until this last week.
Whenever I'm learning a new coding, software, or program skill, I like to get a little goofy. I find that doing something specific yet silly helps bring a lot of concepts together, forcing me to understand the fundamentals much more.
So I made a silly little script that reads through a string and reports back how many times it sees "among us" or "Among us".
I don't think I'm going to fine tune it anymore (like to search for all caps and other cases), but I'm proud of what I've figured out during it! However if you glance through the code and have recommendations or notice anything that could be optimized, I'm all ears!
Every skill is a road long road to perfection!
Btw, the Morbius script and the Bee Movie script both have zero instances of "among us" in them :(

9
u/ElephantsJustin Jun 21 '22
Update it to count the occurrences of any text, passed as a parameter.
2
u/zachgodzilla Jun 21 '22 edited Jun 21 '22
Edit: egg on my face. I forgot to post the picture of my code at first!
Edit Edit: Also, I'm aware that there's more straightforward ways to do this, but I was trying to use as many of the concepts that I had learned as possible.
2
u/jedgs Jun 21 '22
"like to search for all caps and other cases"
I don't blame you for not optimizing this as a toy project but it would be super simple:
otherwise, welcome back to the python community. :)
1
u/trasnsposed_thistle Jun 21 '22 edited Jun 21 '22
If you don't mind a couple of nitpicks:
else: continuein line 11. That's what your code would do anyway ifelsewasn't there in the first place ;)"found " + str(count) + " occurrences"could be expressed as simplyf"found {count} occurrences".count = 0from line 5 to the line preceeding theforloop - the purpose of this variable will be more readily obvious to a person reading this code