Пікірлер
@ankitamarjit8909
@ankitamarjit8909 6 күн бұрын
thanks
@Pav711
@Pav711 20 күн бұрын
Thanks!
@jiminshi_bts_
@jiminshi_bts_ 26 күн бұрын
thank you sir 🌝💗
@Mr.Phantom001
@Mr.Phantom001 Ай бұрын
Thanks mate for this help❤
@user-by4uv2hl5u
@user-by4uv2hl5u Ай бұрын
why does my terminal say Dealer had<function revealdealerhand at 0x00000244ABB568C0> and X but my hand is normal?
@user-by4uv2hl5u
@user-by4uv2hl5u Ай бұрын
this is the code that i use : def revealdealerhand(): if len(dealerhand) == 2: return dealerhand [0] elif len(dealerhand) > 2: return dealerhand [0], dealerhand[1]
@Piktro
@Piktro 2 ай бұрын
I'm brand new to Python, haven't touched any code in 10+ years until 2 weeks ago, but wouldn't it be easier to check certain win conditions during each turn, or at least print the player and dealer hands at the end outside of the if statements, to avoid repeating all that code and all those print statements? For example, immediately after dealing: If player and dealer blackjack, print push. Elif player blackjack, print player wins. Elif dealer blackjack, print dealer wins. In player turn: If player busts, print dealer wins In dealer turn: If dealer busts, print player wins. Then after a player "stand", just compare player vs dealer totals. If player > dealer, print player wins. Elif dealer > player, print dealer wins. Even if we keep the code how it is, wouldn't something like the following be much easier to read? print(f"Player has {total(player_hand)}. Dealer has {total(dealer_hand)}.") if total(player_hand) == 21: print(f"Blackjack, you win!") elif total(dealer_hand) == 21: print(f"Blackjack, dealer wins!") elif total(player_hand) > 21: print(f"Player bust! Dealer wins.") elif total(dealer_hand) > 21: print(f"Dealer bust! Player wins.") elif 21 - total(dealer_hand) < 21 - total(player_hand): print(f"You win!") elif 21 - total(dealer_hand) > 21 - total(player_hand): print(f"Dealer wins!") I've just watched a bunch of tutorials and things like "don't repeat yourself" were hammered into my brain.
@YashviDungrani
@YashviDungrani 2 ай бұрын
# i've tried solving all the problems like if wrong input, user won't switch and computer can't generate same numbers again and again.... # hope this helps import random # creating board board=[ "-", "-", "-", "-", "-", "-", "-", "-", "-"] livePlayer="X" win=None codeRunning=True # print board def prBoard(board): print(' '+board[0] +" | "+ board[1] +" | "+ board[2] ) print("-----------") print(' '+board[3] +" | "+ board[4] +" | "+ board[5] ) print("-----------") print(' '+board[6] +" | "+ board[7] +" | "+ board[8] ) # user(player1) input in board def userIn(board): u_in=int(input("Enter a number btwn 1-9: ")) if u_in >= 1 and u_in <= 9 and board[u_in-1] == '-': board[u_in-1] = livePlayer else: print("WRONG INPUT!!!! Try again...") switchPlayer() # computer(player2) input(random module) def computerIn(board): while livePlayer=='O': for i in board: c=random.randint(0,8) if c not in board and board[c]=='-': c_in=c break print(f"Computer's turn: {c_in+1}") board[c_in]='O' switchPlayer() checkwin() # switch player def switchPlayer(): global livePlayer if livePlayer=='X': livePlayer='O' else: livePlayer='X' # horizontal WIN ||| def rowWin(board): global win if board[0] == board[1] == board[2] and board[0] != '-': win=board[0] return True elif board[3] == board[4] == board[5] and board[3] != '-': win=board[3] return True elif board[6] == board[7] == board[8] and board[6] != '-': win=board[6] return True # vertical WIN --- def columnWin(board): global win if board[0] == board[3] == board[6] and board[0] != '-': win=board[0] return True elif board[1] == board[4] == board[7] and board[1] != '-': win=board[1] return True elif board[2] == board[5] == board[8] and board[2] != '-': win=board[2] return True # criss cross WIN \ / def crossWin(board): global win if board[0] == board[4] == board[8] and board[0] != '-': win=board[0] return True elif board[2] == board[4] == board[6] and board[2] != '-': win=board[2] return True # Tie def tie(board): if '-' not in board: prBoard(board) print("Its a Tie...") codeRunning=False # winning criteria (or tie) def checkwin(): global codeRunning if rowWin(board) or columnWin(board) or crossWin(board): prBoard(board) print(f"The winner is {win} :)") codeRunning=False # Main while codeRunning: prBoard(board) userIn(board) checkwin() tie(board) switchPlayer() computerIn(board) checkwin() tie(board)
@soumitakar4373
@soumitakar4373 2 ай бұрын
Most simplest video on yt, Thanks a lot.
@aruneshrk7520
@aruneshrk7520 3 ай бұрын
Got the output but have some indentation error 😅.
@pavelpolosin2217
@pavelpolosin2217 3 ай бұрын
I don't understand. How is possible to equal board[inp - 1] = current_player. But current_player variable is a string type, and inp - integer
@Aqua001_
@Aqua001_ Ай бұрын
8:28 That [inp-1] is to find the index(Since the player input starts at 1 and the board index starts at 0 we sub the 1) after that we assign the player input to the board accourding to the index. Therefore it is Board[index] = playerInp.
@SlytherinLassie
@SlytherinLassie 3 ай бұрын
I didn't understand the "board[inp-1]" thing in the function of playerInput.
@BoddepallliKeshavaKumar-qx6hp
@BoddepallliKeshavaKumar-qx6hp 3 ай бұрын
very nice video, good explanation and well understood . Thank You
@i11usion
@i11usion 3 ай бұрын
Thank you!
@skylorhamilton9151
@skylorhamilton9151 3 ай бұрын
Oddly I'm getting "oops player is already in that spot when entering 1. 2-9 is cool though. There's a dash in the 1 position in the code just like 2-9. The computer is able to use position 1 though.
@user-vi5kg5ue3h
@user-vi5kg5ue3h 3 ай бұрын
keep going bro
@zihanmubarak1890
@zihanmubarak1890 3 ай бұрын
it's actually beginner friendly
@iwatchanime9789
@iwatchanime9789 3 ай бұрын
HELP great vid i copied it perfectly but im jw how do i get in the terminal mine isnt like urs also i cant run the program it says error "cant find __main__" i put this in a new file im 1 week into coding so i probably didnt do something very basic
@Contentbabyyy
@Contentbabyyy 4 ай бұрын
13:51
@thanapalthanapal9838
@thanapalthanapal9838 4 ай бұрын
tnk u so much, it very helpful
@thanapalthanapal9838
@thanapalthanapal9838 4 ай бұрын
board[inp-1]=="-" this line i can't understand
@TortoiseEnjoyer
@TortoiseEnjoyer 4 ай бұрын
def revealDealerHand(): unindent does not match any outer indentation level :C
@ChorizoConHuevosEnTuBoca
@ChorizoConHuevosEnTuBoca 4 ай бұрын
It sucks cuz it doesn’t have true async
@katana6533
@katana6533 5 ай бұрын
wtf wrong w your voice?
@samatamotors2299
@samatamotors2299 5 ай бұрын
Thank you so much life save!
@the_great_unknown1
@the_great_unknown1 5 ай бұрын
Can someone post the code plz need it for a project in my python class ain't tryna type allthat
@rommepomme13
@rommepomme13 3 ай бұрын
did u get it? pls post
@Misao.
@Misao. 6 ай бұрын
your voice is attractive
@Das_08
@Das_08 6 ай бұрын
Hey your discord invite link is invalid
@gedtoon6451
@gedtoon6451 6 ай бұрын
your game logic does not include both player and dealer have 21 or player and dealer are both bust.
@jammin1336
@jammin1336 6 ай бұрын
This was my first project, i watched a hour long tutorial to learn then i spent 20 minutes making tic tac toe
@Gemini_mind
@Gemini_mind 6 ай бұрын
why are you whispering?
@jonathanhernandez5917
@jonathanhernandez5917 7 ай бұрын
Good explanation but that voice 😂
@jbx6
@jbx6 6 ай бұрын
Not cool to throw shame bro
@user-pu4eb7ew5g
@user-pu4eb7ew5g 7 ай бұрын
Nice video thank you , only had to change it on playerInput , because if there was a "oops blablabla.." it would switch to the next player , so you can fill the rest of the grid with only O or only X if you want : def playerInput(board): while True: user_input = int(input("Enter a number 1-9: ")) if user_input >= 1 and user_input <=9 and board[user_input-1] == "-": board[user_input-1] = currentPlayer break else: print("Oops this place is already taken. Please pick a new numbers !") continue
@faizo007
@faizo007 7 ай бұрын
Well Done!
@StraightAsPodcast
@StraightAsPodcast 7 ай бұрын
The audio and video don't match. The video is a few seconds faster than the audio.
@StraightAsPodcast
@StraightAsPodcast 7 ай бұрын
Nvm it was just my monitor.
@kodama7132
@kodama7132 7 ай бұрын
so with this im finding that if you choose a spot that is already taken, it still switches currentPlayer variable and skips your turn
@Marci.K
@Marci.K 6 ай бұрын
You can fix this by removing switchPlayer() from the while cycle and put it in the playerInput under the if statement
@shyammohan-dd4oc
@shyammohan-dd4oc 7 ай бұрын
W
@omatamaneenyanga1586
@omatamaneenyanga1586 7 ай бұрын
My python isn't showing the board and it Python 3.12.0
@sunitsawant885
@sunitsawant885 7 ай бұрын
Cant run it again please help
@adarabdulaev
@adarabdulaev 8 ай бұрын
Great tutorial
@frankstenner5377
@frankstenner5377 8 ай бұрын
well made, thank you !
@cartoonmultiverse906
@cartoonmultiverse906 8 ай бұрын
Is there an algorithm that allows the player to win randomly? However enjoyed your video and it was really helpful
@Frenk33
@Frenk33 9 ай бұрын
I fucking hate flask
@PeppyHannah
@PeppyHannah 9 ай бұрын
This was really fun to do, thank you so much! Do you think you could possibly do some Python tutorials for complete beginners? The way you teach and explain what you're doing is the best and would love to see it in Python tutorials 😆
@Jammzz_balisong
@Jammzz_balisong 9 ай бұрын
the ace is 11 or 1
@Muhammad.Kashif31
@Muhammad.Kashif31 10 ай бұрын
share the source code plz
@Muhammad.Kashif31
@Muhammad.Kashif31 10 ай бұрын
incredible! where can i get the source code
@hgs142
@hgs142 10 ай бұрын
Gosh his voice is so terrible I can't listen to it
@ricitos2001
@ricitos2001 10 ай бұрын
This video is very usefull because with this i ended my version of the game "BlackJack" I gave yo my like and my sub Thank you for help me
@berringervids
@berringervids 10 ай бұрын
Totally noob at python, but why not use deck = [1,2,3....] and then do decks = deck*4?
@mrx-vx4wr
@mrx-vx4wr 10 ай бұрын
12:50 why the computer doesn't go straight for win?