Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nested if Statement help
#3
Not only can you do >= but also <=, !=, is, and is not.

https://docs.python.org/3/library/stdtyp...comparison

You can also combine two comparisons:
if 3 <= x < 7:
Which is the same as:
if x >= 3 and x < 7:
But looking at your original question I don't think you want ">=". You want separate actions for g < h, g > h and g == h. You already do this with a and b. You have one action if a < b, a different action if a == b, and a third action if a > b. What I think you want for g and h is:
if g > h:
    print('True'):
elif g < h:
    print('False')
else:
    print('Neutral')
Reply


Messages In This Thread
Nested if Statement help - by olliej - Feb-19-2021, 12:40 AM
RE: Nested if Statement help - by BashBedlam - Feb-19-2021, 01:05 AM
RE: Nested if Statement help - by deanhystad - Feb-19-2021, 04:15 AM
RE: Nested if Statement help - by olliej - Feb-19-2021, 05:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  must the if statement in the following tutorial be nested? hsunteik 3 4,600 Dec-24-2016, 11:48 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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