Python Forum
I keep getting errors and I'm lost!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I keep getting errors and I'm lost!
#2
Okay, you're receiving the error because of line 18. The last few lines of the traceback indicate that "if float(score) > 1.0" is generating the problem. Moreover, the problem is that "Quit" cannot be converted to a float. To fix this, you need to check for the entry "Quit" prior to calling float() on the score. Otherwise, you need to use a try...except block to catch the error and then check for "Quit".

As for your second problem, the return is currently inside your while loop. So, at the end of the first iteration, your function is returning the grade that it evaluated. It is returning prior to the second entry being evaluated.

For a critique, you have a lot of repetition in your code. Line 20, for instance, is repeated eight times. To improve your loop, try to refactor it to only have that line appear once.
Reply


Messages In This Thread
RE: I keep getting errors and I'm lost! - by stullis - Oct-27-2018, 03:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I am completely lost on this homework assignment a36 1 1,841 Feb-21-2022, 06:01 AM
Last Post: buran
  Very Lost vollynez 3 1,953 Oct-02-2020, 09:09 PM
Last Post: Yoriz
  I got lost in the program Gadev 1 1,934 Nov-11-2018, 05:50 PM
Last Post: j.crater
  test..and I'm already lost sannixinc 1 2,572 Feb-22-2018, 09:09 PM
Last Post: glidecode
  Completly lost about to fail my class! crakacheezy 7 4,718 Dec-28-2017, 11:50 PM
Last Post: mepyyeti

Forum Jump:

User Panel Messages

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