Python Forum
Cannot figure out what is wrong
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot figure out what is wrong
#2
There are a few issues. First, which version of Python interpreter are you using? (2.7, 3.5, ...). I currently don't have Python 2 installed (which this code seems to be written for), so I didn't give it a test run. But I'm surprised it would run at all.
The information you ask user (planet, lbs) get lost (out of scope) when functions ask_planet and ask_weight are finished. So your calculation cannot access mass, and planet_call cannot access planet. You need to return those values from functions and pass them as arguments to functions that use them.
break will not do what you expect in the if statement, it is used in for and while loops. You can restructure your if statements and check whether user says "yes", "whatever else", or he says "no", in which case don't do anything (else). And print says "please enter yes or no". Your ifs are case sensitive, so only "Yes" and "No" will be accepted. You can get around this with using string's lower() method.
Reply


Messages In This Thread
Cannot figure out what is wrong - by Korbrent - Dec-11-2017, 09:13 PM
RE: Cannot figure out what is wrong - by j.crater - Dec-11-2017, 09:33 PM
RE: Cannot figure out what is wrong - by Korbrent - Dec-11-2017, 09:39 PM
RE: Cannot figure out what is wrong - by squenson - Dec-11-2017, 09:35 PM
RE: Cannot figure out what is wrong - by squenson - Dec-11-2017, 10:14 PM
RE: Cannot figure out what is wrong - by wavic - Dec-11-2017, 11:12 PM
RE: Cannot figure out what is wrong - by Korbrent - Dec-12-2017, 12:00 AM
RE: Cannot figure out what is wrong - by wavic - Dec-12-2017, 12:12 AM
RE: Cannot figure out what is wrong - by Korbrent - Dec-12-2017, 12:17 AM
RE: Cannot figure out what is wrong - by Korbrent - Dec-12-2017, 01:31 AM
RE: Cannot figure out what is wrong - by wavic - Dec-12-2017, 03:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Im so stressed because I cant figure out what I'm doing wrong. BursteXO 2 3,045 Jan-29-2018, 01:16 AM
Last Post: BursteXO

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020