Reputation:
Where am I wrong? The code is running fine, but when I put "COLUMBIA", it's saying "Wrong guess!!". However, the program itself is saying that the answer is "COLUMBIA". I can't figure out why.
L=['INDIA', 'AUSTRALIA',' NETHERLANDS', 'PAKISTAN',' COLUMBIA','SPAIN',
'AUSTRIA',' GERMANY',' ITALY',' POLAND', 'CHINA',' JAPAN', 'FRANCE',
'MEXICO', 'BANGLADESH','MYANMAR','SINGAPORE','NORWAY','RUSSIA',
'SRILANKA' ,'ENGLAND','AMERICA','ALASKA','CANADA','DUBAI']
def space(s):
r=' '
for i in range(len(s)):
if s[i]!='A'and s[i]!='E' and s[i]!='I' and s[i]!='O' and s[i]!='U' and s[i]!=' ':
r=r+' _ '
else:
r=r+s[i]
return r
n=int(raw_input('Enter the number of rounds:'))
score_1=0
score_2=0
import random
for i in range(2*n):
if i%2==0:
x=random.randint(0,25)
a=space(L[x])
print a
b=raw_input('Enter your guess:')
if L[x]==b:
print 'You are correct!!'
score_1+=10
else:
print 'Wrong guess!!'
c=raw_input('Enter your guess :')
if L[x]==c:
print 'You are correct!!'
score_1+=6
else:
print 'Wrong guess!!'
d=raw_input('Enter your guess:')
if L[x]==d:
print 'You are correct!!'
score_1+=3
else:
print 'Wrong guess!!'
print 'The answer is',L[x]
if i%2==1:
x=random.randint(0,25)
e=space(L[x])
print e
f=raw_input('Enter your guess:')
if L[x]==f:
print 'You are correct!!'
score_2+=10
else:
print 'Wrong guess!!'
g=raw_input('Enter your guess :')
if L[x]==g:
print 'You are correct!!'
score_2+=6
else:
print 'Wrong guess!!'
h=raw_input('Enter your guess:')
if L[x]==h:
print 'You are correct!!'
score_2+=3
else:
print 'Wrong guess!!'
print 'The answer is',L[x]
print 'Player 1:',score_1
print 'Player 2:',score_2
Upvotes: 0
Views: 43
Reputation: 352
You have a space in the array entry, ' COLUMBIA'
. Remove the space, and COLUMBIA works fine.
The same is true for a few others, like JAPAN and ITALY.
Upvotes: 2