Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Comparative operators

For someone reason whenever I try to use comparative operators they always yield a syntax error. Even when I use "and" or "or" in an IF statement nothing works. import math

2 Answers

if people < 2: 
  raise ValueError("I am sorry, but you must have atleast 2 people")
  • 'not >' (not greater than) is the same as saying '<' (less than)
  • If you need at least 2 people drop the equal sign as well.

I hope this helps.

-Max

Hey, could you attach any of the code that is giving you a syntax error?

import math

def split(number_people, bill): return math.ceil((bill/number_people))

people = int(input("How many people? ")) if people not >= 2: raise ValueError("I am sorry, but you must have atleast 2 people")

total = int(input("What is the total of your bill? ")) amount_due = split(people, total)

print("Each person owes ${} dollars. Have a great day!".format(amount_due))