Let's code a HANGMAN GAME in Python! 🕺

  Рет қаралды 21,749

Bro Code

Bro Code

Күн бұрын

Пікірлер
@BroCodez
@BroCodez 5 ай бұрын
# Hangman in Python import random hangman_art = {0: (" ", " ", " "), 1: (" o ", " ", " "), 2: (" o ", " | ", " "), 3: (" o ", "/| ", " "), 4: (" o ", "/|\\", " "), 5: (" o ", "/|\\", "/ "), 6: (" o ", "/|\\", "/ \\")} words = ("aardvark", "alligator", "alpaca", "ant", "anteater", "antelope", "ape", "armadillo", "baboon", "badger", "bat", "bear", "beaver", "bee", "bison", "boar", "buffalo", "butterfly", "camel", "capybara", "caribou", "cat", "caterpillar", "cattle", "chamois", "cheetah", "chicken", "chimpanzee", "chinchilla", "chough", "clam", "cobra", "cockroach", "cod", "coyote", "crab", "crane", "crocodile", "crow", "curlew", "deer", "dinosaur", "dog", "dogfish", "dolphin", "donkey", "dormouse", "dotterel", "dove", "dragonfly", "duck", "dugong", "dunlin", "eagle", "echidna", "eel", "eland", "elephant", "elk", "emu", "falcon", "ferret", "finch", "fish", "flamingo", "fly", "fox", "frog", "gaur", "gazelle", "gerbil", "giraffe", "gnat", "gnu", "goat", "goldfinch", "goldfish", "goose", "gorilla", "goshawk", "grasshopper", "grouse", "guanaco", "gull", "hamster", "hare", "hawk", "hedgehog", "heron", "herring", "hippopotamus", "hornet", "horse", "human", "hummingbird", "hyena", "ibex", "ibis", "jackal", "jaguar", "jay", "jellyfish", "kangaroo", "kingfisher", "koala", "kookabura", "kouprey", "kudu", "lapwing", "lark", "lemur", "leopard", "lion", "llama", "lobster", "locust", "loris", "louse", "lyrebird", "magpie", "mallard", "manatee", "mandrill", "mantis", "marten", "meerkat", "mink", "mole", "mongoose", "monkey", "moose", "mosquito", "mouse", "mule", "narwhal", "newt", "nightingale", "octopus", "okapi", "opossum", "oryx", "ostrich", "otter", "owl", "ox", "oyster", "panda", "panther", "parrot", "partridge", "peafowl", "pelican", "penguin", "pheasant", "pig", "pigeon", "polar-bear", "pony", "porcupine", "porpoise", "quail", "quelea", "quetzal", "rabbit", "raccoon", "rail", "ram", "rat", "raven", "red-deer", "red-panda", "reindeer", "rhinoceros", "rook", "salamander", "salmon", "sand-dollar", "sandpiper", "sardine", "scorpion", "seahorse", "seal", "shark", "sheep", "shrew", "skunk", "snail", "snake", "sparrow", "spider", "spoonbill", "squid", "squirrel", "starling", "stingray", "stoat", "stork", "swallow", "swan", "tapir", "tarsier", "termite", "tiger", "toad", "trout", "turkey", "turtle", "viper", "vulture", "wallaby", "walrus", "wasp", "weasel", "whale", "wildcat", "wolf", "wolverine", "wombat", "woodcock", "woodpecker", "worm", "wren", "yak", "zebra") def display_man(wrong_guesses): print("**********") for line in hangman_art[wrong_guesses]: print(line) print("**********") def display_hint(hint): print(" ".join(hint)) def display_answer(answer): print(" ".join(answer)) def main(): answer = random.choice(words) hint = ["_"] * len(answer) wrong_guesses = 0 guessed_letters = set() is_running = True while is_running: display_man(wrong_guesses) display_hint(hint) guess = input("Enter a letter: ").lower() if len(guess) != 1 or not guess.isalpha(): print("Invalid input") continue if guess in guessed_letters: print(f"{guess} is already guessed") continue guessed_letters.add(guess) if guess in answer: for i in range(len(answer)): if answer[i] == guess: hint[i] = guess else: wrong_guesses += 1 if "_" not in hint: display_man(wrong_guesses) display_answer(answer) print("YOU WIN!") is_running = False elif wrong_guesses >= len(hangman_art) - 1: display_man(wrong_guesses) display_answer(answer) print("YOU LOSE!") is_running = False if ___name___ == "__main__": main()
@SGM_26
@SGM_26 5 ай бұрын
Thanks Bro
@Yih-s7j
@Yih-s7j 2 ай бұрын
Thank you so much!!
@ThatScripterConfiy
@ThatScripterConfiy 5 ай бұрын
im a big fan man! you are the best youtuber for python learning and much more i ever seen! i swear!
@spectrogames8
@spectrogames8 5 ай бұрын
I literally made this the day before and yours is completely different from mine
@Winner1vz
@Winner1vz 2 ай бұрын
same
@reminderIknows
@reminderIknows 5 ай бұрын
when i first tried python, i made a hangman game on my own. and it worked much better than expected, everything was fully functional. goes to show that you can learn things easier when it's very similar to something else. (very similar to lua, my main language)
@Jjaewalker
@Jjaewalker 2 ай бұрын
This is literally what im doing now lmao I paused to watch this video
@SGM_26
@SGM_26 5 ай бұрын
Nice, was waiting for another game
@browtfareyou
@browtfareyou 5 ай бұрын
thanks bro, you are the goat python teacher 🐐🐐🐐
@zohaibwaris-q8x
@zohaibwaris-q8x 4 ай бұрын
BRO WON THE GAME LIKE CRAZY FAST (GIGA CHAD)
@thebolt1806
@thebolt1806 5 ай бұрын
Can you please show us one capstone project as well
@nyashachamunokara9787
@nyashachamunokara9787 25 күн бұрын
Hey Bro! Awesome video as always! At 22:36 is there ever a situation whereby our wrong guesses can be greater than 6 and game still continues to play? If not: then should you not have used this code instead (at line 74): if wrong_guesses == 6:
@dysoneducation
@dysoneducation Ай бұрын
Bro is low-key the Best programming teacher in the world 🎉🎉😊
@hybridclasher123
@hybridclasher123 5 ай бұрын
I would love if you make a video on pytorch and neural networks in python.
@Akash-wi4yz
@Akash-wi4yz 5 ай бұрын
Hey! Love your vids man. Can you do a Binary file vid next(I have doubts on writing multiple lines and accessing them). I have an exam on it in 2 days.
@f1yEditssX
@f1yEditssX 5 ай бұрын
Why didnt this blow up yet
@serjan534
@serjan534 5 ай бұрын
thank you sir. best teacher
@kedarp8975
@kedarp8975 5 ай бұрын
Make guides on pandas too!!!
@rzyrandol5848
@rzyrandol5848 5 ай бұрын
what editor do u use?
@tadeucpii
@tadeucpii 2 ай бұрын
What if I wanted to make possible to vuess the full word?
@kedarp8975
@kedarp8975 5 ай бұрын
Love u broo❤❤
@sidnotthesloth1827
@sidnotthesloth1827 5 ай бұрын
Thanks bro!
@johnm3229
@johnm3229 3 ай бұрын
10:31
@artificialintelligencebird
@artificialintelligencebird 5 ай бұрын
Love your videos! Can you make full course for Rust?
@MiguelNunes-t2s
@MiguelNunes-t2s 5 ай бұрын
Actually it's really good because I want to learn rust but I couldn't find a good video to learn rust, and this guy is the best at coding tutorials
@artificialintelligencebird
@artificialintelligencebird 5 ай бұрын
@@MiguelNunes-t2s same I want to learn Rust too
@WongKaiJun-n5y
@WongKaiJun-n5y 7 күн бұрын
goat
@ItsMyAntiDrug
@ItsMyAntiDrug 3 ай бұрын
I'm sure this is fun but mine is not working :_;
@jimams_jamz5518
@jimams_jamz5518 3 ай бұрын
6:43
@jimams_jamz5518
@jimams_jamz5518 3 ай бұрын
10:16
@jimams_jamz5518
@jimams_jamz5518 3 ай бұрын
14:50
@SARVESHDevalekar
@SARVESHDevalekar 4 ай бұрын
My CODE: import random words = { "Lion": "Mammal", "Elephant": "Mammal", "Tiger": "Mammal", "Bear": "Mammal", "Giraffe": "Mammal", "Eagle": "Bird", "Parrot": "Bird", "Penguin": "Bird", "Sparrow": "Bird", "Owl": "Bird", "Snake": "Reptile", "Lizard": "Reptile", "Turtle": "Reptile", "Crocodile": "Reptile", "Chameleon": "Reptile", "Frog": "Amphibian", "Toad": "Amphibian", "Salamander": "Amphibian", "Newt": "Amphibian", "Salmon": "Fish", "Tuna": "Fish", "Goldfish": "Fish", "Shark": "Fish", "Clownfish": "Fish", "Butterfly": "Insect", "Ant": "Insect", "Beetle": "Insect", "Dragonfly": "Insect", "Spider": "Arachnid", "Scorpion": "Arachnid", "Tick": "Arachnid", "Harvestman": "Arachnid", "Daddy Longlegs": "Arachnid" } hangman_art={0:(" ", " ", " "), 1: (" o ", " ", " "), 2: (" o ", " | ", " "), 3: (" o ", "/| ", " "), 4: (" o ", "/|\\", " "), 5: (" o ", "/|\\", "/ "), 6: (" o ", "/|\\", "/ \\")} def disp_man(art,attemptNum): for i in art[attemptNum]: print(i) def disp_Blanks(blanks): print(" ".join(blanks)) count=0 ans_List=[] def check(guess,answer,blanks): global count global attemptNum global running global ans_List if guess=='quit': running=False elif guess in answer: for i in range(len(answer)): if answer[i]==guess: blanks[i]=guess ans_List.append(guess) count+=1 else: attemptNum+=1 print(f'Worng Guess...Try again') attemptNum=0 running=True def main(): global attemptNum global running global ans_List rmdPair=random.sample(list(words.items()),1) answer=rmdPair[0][0].lower() hint=rmdPair[0][1] blanks=['_'] * len(answer) while running: disp_man(hangman_art,attemptNum) print(f'Hint: {hint} ') disp_Blanks(blanks) guess=input('Enter the guess: ') if guess in ans_List: print(f'\'{guess}\' IS PREVIOUSLY USED... CANNOT USE AGAIN') attemptNum+=1 continue check(guess,answer,blanks) if len(ans_List)==len(answer): print(f'____CORRECT____') break elif attemptNum==6: disp_man(hangman_art,attemptNum) print(f'WRONG GUESSES.... ANSWER= {answer}') running=False if __name__=='__main__': main()
@zohaibwaris-q8x
@zohaibwaris-q8x 4 ай бұрын
I Played Your game It's good.
@allennaik4434
@allennaik4434 5 ай бұрын
thanks Bro
@Felipells2633
@Felipells2633 Ай бұрын
im doing this : import random words = ("apple", "orange", "banana", "pineapple", "coconut") #dictionary of key:() hangman_art = {0: (" " " " " "), 1: (" o " " " " "), 2: (" o " " | " " "), 3: (" o " "/| " " "), 4: (" o " "/|\\ " " "), 5: (" o " "/|\\" "/ "), 6: (" o " "/|\\" "/ \\")} for line in hangman_art[0]: print(line) but instead of printing like in the video is showing like this : o / |
@Felipells2633
@Felipells2633 Ай бұрын
my god i forget the , in each key thats why going to leave this here so i can remember my newbness
@EmilioAt77
@EmilioAt77 5 ай бұрын
Bro, you legend ❤️❤️
@KyriproShorts
@KyriproShorts 5 ай бұрын
Sure! Lets do it..... Wait why is it not working??? Error, Error, Error, Error.
Learn Python Object Oriented Programming! 🚗
12:18
Bro Code
Рет қаралды 33 М.
God-Tier Developer Roadmap
16:42
Fireship
Рет қаралды 7 МЛН
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН
БОЙКАЛАР| bayGUYS | 27 шығарылым
28:49
bayGUYS
Рет қаралды 1,1 МЛН
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 387 М.
Can you fit a whole game into a QR code?
20:03
MattKC
Рет қаралды 9 МЛН
Let's code a DIGITAL CLOCK in Python! 🕒
16:25
Bro Code
Рет қаралды 10 М.
you need to learn Python RIGHT NOW!! // EP 1
17:42
NetworkChuck
Рет қаралды 2,5 МЛН
Nature's Incredible ROTATING MOTOR (It’s Electric!) - Smarter Every Day 300
29:37
SUPER() in Python explained! 🔴
13:06
Bro Code
Рет қаралды 15 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 298 М.
How I Would Learn Python FAST in 2024 (if I could start over)
12:19
Thu Vu data analytics
Рет қаралды 632 М.
20 Programming Projects That Will Make You A God At Coding
14:27
The Coding Sloth
Рет қаралды 1,5 МЛН
The World Depends on 60-Year-Old Code No One Knows Anymore
9:30
Coding with Dee
Рет қаралды 1 МЛН