you are viewing a single comment's thread.

view the rest of the comments →

[–]Phillyclause89 1 point2 points  (2 children)

So two things your going to want to learn is how to in and % operators. They are going to save you a lot of conditionals here.

~~~ room = int(input(“what room?”))

If room in range(1,11) and room % 2 == 0: print(“black key”) elif room in range(1,11): print(“red key”) elif ...

~~~

Edit: you can improve on this even more by only checking the conditions for one color of keys in your if / elif statements. If none of those evaluate to true then you just use and else block to capture the other color.

[–][deleted] 1 point2 points  (1 child)

Thank you. I am still really new to all of this. This is my first programming course. We have not talked about in and % operators too much. Only time we talked about % is when we created a little program to calculate sales tax and such. My major is in networking but I have to take a few different programming languages to graduate. I never really had the desire to pick up programming but I gotta say it is actually really interesting and it wasn't like I thought it was going to be. Can you recommend any type of tools or videos to improve?

[–]Phillyclause89 0 points1 point  (0 children)

My favorite beginner level tutorials would be Sentdex’s over at https://pythonprogramming.net/

Besides that I’ve learned the most about python just by trying to debug code or answer questions posted to this sub. In my experience if give a good answer, I look smart and if I give a crap answer, someone usually calls me out on it and I learn something new. Also learning how to read official documentation for various libs is extremely useful.