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 trialJames Tarala
278 PointsAtributeError object has not attribute 'lower'
I am following the coding example exactly. However, when I assign the 'lower' attribute to my variable, it throws an error: 'NoneType' object has not attribute 'lower'.
TICKET_PRICE = 10
TICKETS_REMAINING = 100
while TICKETS_REMAINING >= 1:
print(f"There are currently {TICKETS_REMAINING} tickets left!")
name = input("What is your name? ")
num_tickets_wanted = input(f"Hello, {name}! How many tickets would you like? ")
num_tickets_wanted = int(num_tickets_wanted)
total_price = num_tickets_wanted * TICKET_PRICE
print(f"The cost of {num_tickets_wanted} tickets is ${total_price}, {name}.")
proceed = print(input("Would you like to proceed, Y or N? "))
if proceed.lower() == "Y":
print("Sold!")
TICKETS_REMAINING -= num_tickets_wanted
else:
print(f"Thank you anyways, {name}")
print("Sorry, the tickets are all sold out.")
1 Answer
Steven Parker
231,198 PointsOn this line:
proceed = print(input("Would you like to proceed, Y or N? "))
The result of calling "print" is being assigned to the variable "proceed", but "print" doesn't return anything. So the attemt to call proceed.lower()
on the next line fails.
My guess is that you really intended to write this instead:
proceed = input("Would you like to proceed, Y or N? ")
β¦which would return a string that you could call "lower()" on.
For future questions, it would be nice if the question was linked to a lesson page.
Take a look at this video about Posting a Question for information on doing that.
James Tarala
278 PointsAwesome! Thank you! Not sure how I didn't catch that.
Steven Parker
231,198 PointsAlso notice that the conditional on the next line will never succeed because after conversion to lower case, the input cannot match "Y" which is in upper case.
James Tarala
278 PointsJames Tarala
278 PointsNot to mention, this code doesn't run properly also. It's not looping correctly. I have replicated what was done in the video almost exactly (except for the f-strings). Any help is definitely appreciated!