forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11688b0
commit 167d8ef
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [Fácil]/python/majinka10.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |