Last active
March 21, 2022 16:34
-
-
Save Glutexo/369b980db3b93627c7538461ca33b519 to your computer and use it in GitHub Desktop.
Hra na myšlenou potvoru
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
🐵🐒🦍🦧🐶🐕🦮🐩🐺🦊🦝🐱🐈🦁🐯🐅🐆🐴🐎🦄🦓🦌🦬🐮🐂🐃🐄🐷🐖🐗🐽🐏🐑🐐🐪🐫🦙🦒🐘🦣🦏🦛🐭🐁🐀🐹🐰🐇🐿️🦫🦔🦇🐻️🐨🐼🦥🦦🦨🦘🦡🐾🦃🐔🐓🐣🐤🐥🐦🐧🕊️🦅🦆🦢🦉🦤🪶🦩🦚🦜🐸🐊🐢🦎🐍🐲🐉🦕🦖🐳🐋🐬🦭🐟🐠🐡🦈🐙🐚🐌🦋🐛🐜🐝🪲🐞🦗🪳🕷️🕸️🦂🦟🪰🪱🦠 |
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
from random import choice | |
from random import randrange | |
def načti_pokémony(): | |
from csv import reader | |
with open("Pokemon.csv") as file: | |
csvfile = reader(file) | |
next(csvfile) | |
return [line[1].upper() for line in csvfile] | |
def načti_zvířata(): | |
from unicodedata import name | |
with open("animals.txt") as file: | |
return [name(zvíře) for zvíře in file.read().rstrip()] | |
from random import choice | |
from random import randrange | |
potvory = načti_pokémony() | |
# potvory = načti_zvířata() | |
namyšlené = choice(potvory) | |
nápověda = "*" * len(namyšlené) | |
zakryto = list(range(len(namyšlené))) | |
while True: | |
hádané = input(f"Co si myslím za potvoru? 🤔\nHádej písmena, nebo celé slovo.\nNápověda: {nápověda}\n") | |
if len(hádané) == 1 and hádané in namyšlené: | |
odkryto = [znak for znak, písmeno in enumerate(namyšlené) if písmeno == hádané] | |
for znak in odkryto: | |
zakryto.remove(znak) | |
nápověda = nápověda[0:znak] + namyšlené[znak] + nápověda[znak + 1:] | |
if nápověda == namyšlené: | |
print(f"Vyhrál jste, řízku! 🥩 {namyšlené}") | |
break | |
else: | |
print("Trefa! 👍🏻") | |
elif hádané == namyšlené: | |
print(f"Bingo! 🎉 {namyšlené}") | |
break | |
elif hádané == "": | |
print("Srabe. 🖕🏻") | |
break | |
else: | |
print("Ale kdeže. 🤦🏻♂️") | |
znak = choice(zakryto) | |
zakryto.remove(znak) | |
nápověda = nápověda[0:znak] + namyšlené[znak] + nápověda[znak + 1:] | |
if "*" not in nápověda: | |
print(f"Prohrál jste, saláte. 🥗\nNamyšlená potvora byla {namyšlené}.") | |
break |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
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
Stáhněte si z https://raw.githubusercontent.com/frenzymadness/Data_analysis_workshop/master/data/Pokemon.csv. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment