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.
2 Answers 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
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
lang-py
.upper()
input with lowercase array.