How not to detect upper case in Python 3.5

3

I've done a program in Python 3.5 to ask myself words. But I have a problem:

dictionary = {}

numpal = int(input("Cuantas palabras quieres que te pregunte?: "))
if numpal<=0:
    print("El numero de palabras tiene que ser mayor que 0.")
    numpal = int(input("Cuantas palabras quieres que te pregunte?: "))

count = 0

for i in range(numpal):
    palabra = str(input("\nEscribe aqui la palabra: "))
    traduccion = str(input("Escribe aqui la traduccion de {0}: ".format(palabra)))
    dictionary[palabra] = traduccion
for palabra, traduccion in dictionary.items():
    print('\nCual es la traduccion de "{0}"?'.format(palabra))
    respuesta = input("\nEscribe aqui la traduccion: ")


    if respuesta == traduccion:
        print("La respuesta es correcta.")
        count = count + 1
    else:
        print("La respuesta es incorrecta.")

nota = float(count / numpal * 9 + 1)
print('Tu nota es un ' + str(nota)+ '.')

if nota < 6:
    print('Uy, necesitas estudiar mas tus palabras .')
elif nota > 8:
    print ('Perfecto! Sabes tus palabras perfectamente.')
else:
    print('Dominas las palabras, pero te recomiendo que estudies un poco mas.')
  

Output

Cuantas palabras quieres que te pregunte?: 2

Escribe aqui la palabra: Gato
Escribe aqui la traduccion de Gato: Cat

Escribe aqui la palabra: Perro
Escribe aqui la traduccion de Perro: Dog

Cual es la traduccion de "Gato"?

Escribe aqui la traduccion: Cat
La respuesta es correcta.

Cual es la traduccion de "Perro"?

Escribe aqui la traduccion: DOG  

#Quiero que esto me lo cuente como respuesta correcta,que de igual si lo escribes con mayusculas o minusculas.

La respuesta es incorrecta.
Tu nota es un 5.5.
Uy, necesitas estudiar mas tus palabras .

How can you see, if I put the word in capitals or something that is not what I have put in the translation, it gives me an incorrect answer. How can I solve this problem and recognize the word even if it has lowercase or uppercase?

    
asked by user28359 23.01.2017 в 12:01
source

1 answer

1

In your line of comparison

 if respuesta == traduccion:

Pon:

respuesta.lower() == traduccion.lower():

So that you pass them all to lowercase and compare independently of the saved and entered capital letters.

If you put DOG and the translation is Dog when comparing it will be a "dog" == "dog" which is True

    
answered by 23.01.2017 / 12:24
source