2

My Code:

team = ['barca', 'madrid']
fav_team = raw_input('What is your favorite team: ')
fav_team = fav_team.upper()
if fav_team in team:
 print "AWESOME"

Hello. I'm very new to programming, i have zero experience and I'm trying to make this work. But when i run this code, its not printing anything. I want to be able to make the user input his favorite team, and something prints out. But nothing comes out. how do i get the print statement to show?. I already tried using the input function and that did not work.

asked Oct 5, 2015 at 9:45
1
  • 4
    I'm no python expert, but you are comparing .upper() input with lowercase array. Commented Oct 5, 2015 at 9:48

2 Answers 2

2

You need to call lower function.

team = ['barca', 'madrid']
fav_team = raw_input('What is your favorite team: ')
fav_team = fav_team.lower()
if fav_team in team:
 print "AWESOME"
answered Oct 5, 2015 at 9:48
1
team = ['barca', 'madrid']
fav_team = raw_input('What is your favorite team: ')
fav_team = fav_team.lower() #make upper lower
if fav_team in team:
 print "AWESOME"

You need to make your upper lower as list contains elements in lower.

This will still have errors if list has capitals. So make both lowercase.

if fav_team in map(str.lower,team):
 print "AWESOME"
Biffen
6,3856 gold badges32 silver badges38 bronze badges
answered Oct 5, 2015 at 9:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.