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!

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 Python Basics (Retired) Shopping List Shopping List Project

Understanding Greater than symbol Python "> "

My code is as follows:

shopping_list = list()

print("What should we pick up at the store?")
print("Enter 'DONE' to stop adding items.")

while True:
  new_item = input("> ")

  if new_item == 'DONE':

  print("Added! List has {} items.".format(len(shopping_list)))

print("Here's your list:")

for item in shopping_list:

I don't understand what the

while True:
  new_item = input("> ")


while the input of new_item is (What?)

Can someone help me understand what this means ("> ") and why it is being used?

I assume it must mean anything? Because it would be = anything - 'DONE' can be an input for new_item.


1 Answer

Hi Jake

The input method take an argument which is displayed just before the user input. So "> " just resembels a symbol to prompt the user that he need to enter somthing. you then store the user input in a variable called new_item.

 # you could have also written it like so

   new_item = input("Ok so what do you want to pick up ?    " )  

Ohh wow makes sense thank you !

One other question -- what does list() represent / mean ?

Hi Jake

a list in python is similar to an array in other languages. you can declare a variable as list like above shopping_list = list() or you could use the shorthand notation of a list which is [], so you could also have declared shopping_list = [] which would be the same thing.

hope that makes sence.

Sorry, I understand what a list is however, not what list() (the open and closing brackets with nothing in it), nor what [] would mean otherwise.


Wait, it just means we are starting an empty list...?

the opening and closing parenthesis means you are creating an object of the built in list class i.e your creating an empty list

so if i have a class called Cat for example and i wanted to create an object of this cat class i would do it like so

mycat = Cat()

# then if the class Cat has any methods i could access them like so