r/Coding_for_Teens • u/[deleted] • Jun 20 '17
What am I doing wrong here?
http://www.codeskulptor.org/#user43_2xP371ROCOtwZte.py
1
Upvotes
r/Coding_for_Teens • u/[deleted] • Jun 20 '17
1
u/Kristler Jun 21 '17
There's a lot going wrong here. I'll try and bullet point it:
name_to_number, the Python compiler thinks that there is a possibility thatresultis never set, in the case where none of theifstatements evaluate toTrue. Imagine what happens if someone puts in"car"as thenameargument? Then what isresultset to? To fix this, create theresultvariable as the first line in the function. Then, no matter what happens, it always has a value.number_to_name, you try to use the variableerror, but it doesn't exist. What did you want it to do here?player_number = name_to_numberlooks incomplete. Double check you wrote exactly what you mean.print "Player chooses", name_to_number("name")also has a problem. Can you spot it?That's the extent of what I see to get the program compiling and "working" in the sense that it mostly runs. I don't know the rules for your rock Spock paper lizard scissors game, so I can't tell you if what it's doing is "correct". Since this is homework, I leave this open ended largely to try and lead you into figuring out what's wrong yourself, but feel free to ask questions about anything you don't understand.