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
#10
Alright, so on the subject of variables, I did some messing around to try to do what sparkz_alot said, and I took a couple lines out and came up with this little "test" to see if it would work...

def ask_weight():
    lbs = float(input("How many pounds do you weigh? "))
    return lbs
ask_weight()
print str(lbs)
Even though I returned the value for lbs, it would not print the inputted value.

(Dec-12-2017, 12:00 AM)Korbrent Wrote:
(Dec-11-2017, 11:41 PM)sparkz_alot Wrote: Your 'planet_call()' only needs one print statement, the pythonic way would be:
print("Your weight on {} would be {} pounds".format(planet, pounds))
For now, forget about asking for new planets. See if you can get the 'base' working correctly. As was also pointed out, Python is case sensitive so make sure your variables are of the same case.

I do not think the format command is in this version of python.

Edit: I figured out in this version of python it would be:
print("Your weight on %s would be %d pounds."%(planet, pounds))

Nevermind, both ways work. I just forgot to add the period before format.
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,051 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