Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

397
Views
'AttributeError: 'tuple' object has no attribute 'lower'' - Why doesn't the '.lower()' method doesn't work here in Python?

I am currently learning python and doing the exercises in the module. I have learned previously how to remove any case letter in the string, so it will be easier for the user to use it later on. But it seems like when I applied the ' XXX.lower() ' method to my code, it doesnt work. It works just fine without the '.lower()' method but I really want to know why it doest work ? Here's my code :

# bird names list
bird_names = ("Parrot", "Owl", "Pigeon", "Crow", "Peacock", "Hen")

# bird guess
bird_guess = input("Enter a bird name (Guess 1): ")

# nested conditions starts here
if bird_guess.lower() in bird_names.lower():
  print("Yes, 1st try!")
else:
  bird_guess = input("Enter a bird name (Guess 2): ")
  if bird_guess.lower() in bird_names.lower():
    print("Yes, 2nd try!")
  else:
    bird_guess = input("Enter a bird name (Guess 3): ")
    if bird_guess.lower() in bird_names.lower():
      print("Yes, 3rd try!")
    else:
      print("Sorry, out of tries.")
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

bird_names is a tuple, .lower() is supposed to be called on a string. You might want to consider something like

bird_names = ("Parrot", "Owl", "Pigeon", "Crow", "Peacock", "Hen")
bird_names = [name.lower() for name in bird_names]

and then you can use

if bird_guess.lower() in bird_names:
    ....
over 4 years ago · Santiago Trujillo Report

0

Because bird names is a tuple object not a string. In order for this to work what you can do is updating or overwriting the existing tuple with a list comprehension or generating a new variable. Instead of bird_names.lower() you can use the new list or tuple in the conditions.

bird_names_lower = [bird.lower() for bird in bird_names]
over 4 years ago · Santiago Trujillo Report

0

  • bird_names is a list object
  • .lower() is a string function

maybe something like this can help you:

if bird_guess.lower() in [word.lower() for word in bird_names]:
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!