Skip to content

Commit

Permalink
Reto mouredev#47 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
guillepinto committed Jan 31, 2024
1 parent 11688b0 commit 167d8ef
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diccionario = {}

for i, code in enumerate(range(65, 91)):
if i+1 < 15:
diccionario[chr(code)] = i+1
else:
diccionario[chr(code)] = i+2
else:
diccionario[chr(209)] = 15

def puntos_palabra(diccionario: dict, palabra: str) -> int:
valor = 0
for letra in palabra:
valor += diccionario[letra.upper()]
return valor

def leer_palabra():
while True:
entrada = input("Introduce una palabra\n")
if entrada.isalpha() and len(entrada) > 0:
return entrada
else:
print("La entrada debe ser una palabra.")

def onehundred_word():
palabra = leer_palabra()
valor = puntos_palabra(diccionario, palabra)
if valor != 100:
print(f'Esta palabra tiene {valor} puntos!')
return onehundred_word()
else:
return 'Felicitaciones!. Encontraste una palabra de 100 puntos.'

print(onehundred_word())

0 comments on commit 167d8ef

Please sign in to comment.