Python Forum
Frustrated with Assignment. S.O.S! HELP!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Frustrated with Assignment. S.O.S! HELP!
#7
Note that a line that is just True or just False does nothing. You need to assign that value or return it or something. Otherwise it just disappears.

Me thinks the simplest way to do this is to check each rule for failure. If it fails, return False. This ends the function, and is called short circuiting the calculation, as buran mentioned. Then at the end, you return True. That will only happen if none of the tests failed.

def validate(text):
    if text[0] != 4: 
        return False
    ...
    return True
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Frustrated with Assignment. S.O.S! HELP! - by ichabod801 - Nov-18-2019, 01:28 PM
return in my function - by Than999 - Nov-17-2019, 08:32 PM
RE: return in my function - by perfringo - Nov-18-2019, 10:37 AM

Forum Jump:

User Panel Messages

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