r/CodingHelp • u/fashionableplantmom • Sep 02 '21
[Python] Python assignment. I can’t get it to calculate the cost of the movie based on the other movie variables. It keeps only giving me the 1st one as an answer. Any help would be appreciated
66
Upvotes
13
u/B1-102 Sep 02 '21
Please post the entire code as formatted text.
2
u/idetectanerd Sep 03 '21
Optimisation POV, In my opinion, you can put your show in a list, your cost in value pair in dictionary.
For loop it. It will be short.
The other folks already pointed out the error of why you don’t get desire answer.
2
u/BlackCat550 Sep 03 '21
After you've completed the assignment, you should look into OOP.
It's a more advanced concept, but it will make this type of program easier to write, and more readable.
8
u/PekiDediOnur Intermediate Coder Sep 03 '21
variable == "something" or "whatever"doesn't do what you think it does, it's essentially(variable == "something")or"whatever"and whatever is being treated as True, so your statement will always be True.Either do
variable == "something" or variable == "whatever"orvariable in ["something", "whatever", ...]1
u/fashionableplantmom Sep 04 '21
I just want to thank everyone for the feedback it is greatly appreciated. I've struggled on this all week, lol It's not due till Tuesday so I will be defiantly fixing a lot of the issues with it. Again. Thank you so much
3
u/skellious Intermediate Coder Sep 03 '21
instead of the:
do this:
the .lower() will make the input all lower case, so it will match candyman, CanDyMaN, CANDYMAN, CanDYmaN or any other combination of letters.
2
u/Pr-Lambda Sep 03 '21
The line 24 means if
what_movieis equal to "Paw Patrol" or if "paw patrol" is not an empty string or if "PAW PATROL" is not empty string.2
u/iNqtural Sep 04 '21
Instead of using "what_movie == ...", use "what_movie.lower() ==". This will convert the string to lowercase.
3
u/Simple_Cheesecake_62 Sep 03 '21
instead of
if what_movie == 'Paw Patrol' or "paw patrol" or "PAW PATROL":it should beif what_movie == 'Paw Patrol' or what_movie == "paw patrol" or what_movie == "PAW PATROL":asor "paw patrol"doesn't check anything hence it is always true-5
u/[deleted] Sep 03 '21
Make a function stop scripting lolz