import random options = ("rock", "paper", "scissors") running = True while running: player = None computer = random.choice(options) while player not in options: player = input("Enter a choice (rock, paper, scissors): ") print(f"Player: {player}") print(f"Computer: {computer}") if player == computer: print("It's a tie!") elif player == "rock" and computer == "scissors": print("You win!") elif player == "paper" and computer == "rock": print("You win!") elif player == "scissors" and computer == "paper": print("You win!") else: print("You lose!") if not input("Play again? (y/n): ").lower() == "y": running = False print("Thanks for playing!")
I found a simpler and more efficient way to do it: Basically instead of of making three individual if statements to check the win condition, I added a second tuple after that's ordered like this: options = ("rock", "paper", "scissors") winning = ("scissors", "rock", "paper") so that I don't need to check any win conditions, I just need to check that the index of player choice in the options is the same as the index of computer's choice in winning tuple, if they are the player wins. Also, I added .lower() right after input so that SCISSORS will work as well as scissors import random options = ("rock", "paper", "scissors") winning = ("scissors", "rock", "paper") running = True while running: player = None computer = random.choice(options) while player not in options: player = input("Enter a choice (rock, paper, scissors): ").lower() print(f"Player: {player}") print(f"Computer: {computer}") if player == computer: print("It's a tie!") elif options.index(player) == winning.index(computer): print("You win !") else: print("You lose!") if not input("Play again? (y/n): ").lower() == "y": running = False print("Thanks for playing!")
I'm glad you're still on UA-cam, you help thousands of people with your videos oh and your fundraiser is very self less as well. Keep doing this I believe in you
Thank you so much that you dedicated your precious time for us to tech python. Please don't stop making videos from python. We learn alot from you and tomorrow we will change the world . We are proud of you. We are hungry for your python videos and we are supporters of you. Thanks again.
print('''welcome to stone paper scissor game''') d=input("press enter to start the game") while True: import time print("stone........") time.sleep(0.44) print("paper.....") time.sleep(0.7) print("scissor............") time.sleep(0.9) import random l=input("enter your choice --->") time.sleep(0.99) o=("paper","stone","scissor") k=random.choice(o) print("the choice of computer is",k) if (l=="stone" and k=="scissor"): print("you won") elif (l=="stone" and k=="paper"): print('you loose') elif (l=="stone" and k=="stone"): print('draw') if (l=="paper" and k=="stone"): print("you won") elif (l== "paper" and k=="scissor"): print("you loose") elif (l=="paper" and k=="paper"): print("draw") if (l=="scissor" and k=="paper"): print("you won") elif (l=="scissor" and k=="stone"): print("you loose") elif (l=="scissor" and k=="scissor"): print("draw") time.sleep(2) p=input("Do you want to try again enter yes or no---->") if p=="yes": continue elif p=="no": print("thanks for playing") break
Thanks for making these videos man, I love improving on what you've laid out for me, or changing it's function and how it works. For instance, in this video I wasn't satisfied with the system for checking if the player was cheating, so I made my own: while True: player = input('Rock, Paper or Scissors?: ').capitalize() if player in options: break else: print(f'Picking a {player} is cheating! Pick again') Many thanks once again,
My solution: Instead of checking every input through the if statement i have declared a dictionary with posible winning combinations. -------------------- import random options = ("rock", "paper", "scisors") computer = random.choice(options) human = input("Rock, paper of scisors?: ").lower() winner_combo = {"rock": "scisors", "paper": "rock", "scisors": "paper"} for key, value in winner_combo.items(): if computer == key and human == value: print("Computer is a winner!")
if computer == value and human == key: print("Human is a winner!")
if computer == human: print("Draw!") break -------------- Of course i could put this whole thing in a while loop, but i didn't want to do that...
import random running = True while running: input("Rock, Paper or Scissors: ") print(random.choice(["Draw", "You Lost", "You Won"])) ^makes it infinite
With the statement: if not input("Play again? (y/n): ").lower() == "y": running = False The game will end if the answer is neither "y" nor "n", isn't it? I can only come up with the following code as an alternative: while True: play_again = input("Play again? (y/n): ").lower() if play_again == "y": break elif play_again == "n": running = False print("Thanks for playing!") break else: continue Can we simplify my alternative code further?
My attempt! Did before seeing the video, so it's kinda different lol import random print(" "*2) print("PEDRA PAPEL OU TESOURA") opcoesppt = ("pedra", "papel", "tesoura") plr = 0 bot = 0 # pedra < papel < tesoura while bot < 3 and plr < 3: print(F"{plr} / {bot}") print(" "*2) mao = input("Pedra, Papel ou Tesoura??????: ") opcoes = random.choice(opcoesppt) if mao.lower() in opcoesppt:
print(" "*2) print(f"{mao} VS {opcoes}") print() if opcoes == "pedra": if mao == "papel": print("GANHOU! Papel cobre pedra!") plr += 1 elif mao == "tesoura": print("PERDEU! Pedra quebra a tesoura!") bot += 1 else: print("EMPATE!!! Pedra ama pedra!")
if opcoes == "papel": if mao == "pedra": print("PERDEU! Papel cobre pedra!") bot += 1 elif mao == "tesoura": print("GANHOU! Tesoura corta papel!") plr += 1 else: print("EMPATE!!! Papel papel pepel")
if opcoes == "tesoura": if mao == "papel": print("PERDEU! Tesoura corta papel!") bot += 1 elif mao == "pedra": print("GANHOU! Pedra quebra a tesoura!") plr += 1 else: print("EMPATE!!! ( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)")
else: print() print(f"{mao} é INVALIDO! escolha pedra, papel ou tesoura!! >:(") if plr == 3: print(f" VOCE GANHOU!!!! ") print(f" Voce : {plr} vs Bot : {bot}") print() elif bot == 3: print(f" VOCE PERDEU :( ") print(f" Voce : {plr} / Bot : {bot}") print()
you can also use a dictionary with the keys being one play and the value the equivalent that loses to it to check for a win, just need to check if dict[player] == cpu
the code that you sent is working fine but for the player options if we write gun or something which is not in the options it is still giving me the answer. can you modify the code to prohibit the logical error
hello bro, I want to ask a question how do you do this in python I want to do this 1,2,3,4=[pie,bro,code,james] and when i say print the number is should print a particular number in the list. I hope you understand
Hi Im doing wed site work in school in vs code (you helped my so much,thank you for that) and the rest of the class did it in visual studio. We strted to learn MasterPage and i dont now how to creat one and use it in vs code, and now i got screwed, i cheked all over the internt and i didnt find help. Can you help my or it impossible?
import time import random PLAYER_NAME = input("Hello, welcome to rock paper scissors what's your name? ") _round = 0 computer_wins = 0 player_wins = 0 for i in range(0, 10, 1): i = str(i) PLAYER_NAME = PLAYER_NAME.replace(i, "").capitalize() print("reminder! {} you can always quit the game by pressing q in the input".format(PLAYER_NAME)) print() time.sleep(2) while True: options = ["rock", "paper", "scissors"] computer_choice = random.choice(options) _round += 1 print("round {}".format(_round)) player_choice = input("rock/paper/scissors: ").lower() if player_choice == "rock" and computer_choice == "scissors" or player_choice == "paper" and computer_choice == "rock" or player_choice == "scissors" and computer_choice == "paper": print() print("You won this round!") print("computer picked {}!".format(computer_choice)) player_wins += 1 print() time.sleep(1) if player_choice == "q": print() print("sorry to see you leave, {} :( Bye!".format(PLAYER_NAME)) quit() if player_choice == computer_choice: print() print("Tie!") time.sleep(1) print() if computer_choice == "rock" and player_choice == "scissors" or computer_choice == "paper" and player_choice == "rock" or computer_choice == "scissors" and player_choice == "paper": print() computer_wins += 1 print("You lost, computer picked {}".format(computer_choice)) time.sleep(1) print() result = options.count(player_choice) if result > 0: pass else: print("That's not a valid option please retry!") print() continue ty = input("press r for results and enter to continue or q to quit: ") if ty == "r": print() time.sleep(1) print("Computer wins =", computer_wins) print("{}'s wins =".format(PLAYER_NAME), player_wins) time.sleep(1) print() continue if ty == "": print() time.sleep(1) continue if ty == "q": print() print("sorry to see you leave, {} :( Bye!".format(PLAYER_NAME)) quit()
Srry im so dumb, can you explain this part to me? for i in range(0, 10, 1): i = str(i) PLAYER_NAME = PLAYER_NAME.replace(i, "").capitalize() i think its to capitalize the first letter, but i dont understand why the use of for in range and the i / replace thing
@@luquinhamottinhaclipinhos3785 i did this so if the user inserts any number it gets deleted, so i = 0 - 9, if there is any number, we delete it, try it for ur self see what happens
I tried this code but it says “”continue” can be used only within a loop” any idea as to why? I’m completely new to this so I have no idea what the problem is and why it won’t let me run the code
so there are two functions, continue and break, both of them are used in loops, lemme tell you how they work, continue: we use this to go to back to the start of the loop, i had it in the if statement to check if its an invalid response to make go to the beginning of the loop and check for another answer again until its correct, and break is the exact opposite of continue, we put it in an if statement (i dont have it in this code), but we use it to exit the loop, and run the rest of the code outside the loop... hope i have helped you :) @@friendyz9986
#pythonrockpaperscissorsgame : import random print("I'm a Python R.P.S Game 🗿.") options = ("rock", "paper", "scissors") running = True while running: player = None computer = random.choice(options) while player not in options: player = input("Enter a choice (rock, paper, scissors): ") print(f"Player: {player}") print(f"Computer: {computer}") if player == computer: print("It's a tie!") elif player == "rock" and computer == "scissors": print("You win!") elif player == "paper" and computer == "rock": print("You win!") elif player == "scissors" and computer == "paper": print("You win!") else: print("You lose!") if not input("Play again? (y/n): ").lower() == "y": running = False print("Thanks for playing!")
BROO... i was watching this video and it went private what the hell happened!! Anyways im happy again. All the other youtubers start using complicated commands that beginners dont understand yet. Lots of love for your content!
i did : ``` import random a = ["rock" , "paper" , "scissor"] userwins = 0 computerwins = 0 ties = 0 for _ in range(10): print("rock, paper, scissor GO! ") randomnumber = random.randint(0,2) b = a[randomnumber] userinput = input("> ").lower() if userinput == 'rock' or 'paper' or 'scissor': if b == a[0]: if userinput == "paper": print("YOU WON! ") print(f"The computer played : {b}") userwins += 1 elif userinput == "scissors": print("you lost...") computerwins += 1 print(f"The computer played : {b}") elif userinput == "rock": print("Its a tie") print(f"The computer played : {b}") ties += 1 else: print("ERROR please input rock, paper or scissor") elif b == a[1]: if userinput == "scissor": print("YOU WON! ") print(f"The computer played : {b}") userwins += 1 elif userinput == "rock": print("you lost...") computerwins += 1 print(f"The computer played : {b}") elif userinput == "paper": print("Its a tie") print(f"The computer played : {b}") ties += 1 else: print("ERROR please input rock, paper or scissor") elif b == a[2]: if userinput == "rock": print("YOU WON! ") print(f"The computer played : {b}") userwins += 1 elif userinput == "paper": print("you lost...") computerwins += 1 print(f"The computer played : {b}") elif userinput == "scissor": print("Its a tie") print(f"The computer played : {b}") ties += 1 else: print("ERROR please input rock, paper or scissor") else: print("ERROR, please input rock, paper or scissor! ") print(f"games the computer won : {computerwins}") print(f"games you won : {userwins}") print(f"ties between you and the computer : {ties}") ``` how do you like my code?
Can you make the play again message reappear if the player types something random instead of yes or no instead of ending a game if the player types soemthing like flshflkafhkjlashkjlhfkljhfkljshfkjls?
import random while True: choice = ["roc", "pap", "sci"] comp = random.choice (choice) human = "" while human not in (choice): human = input("roc,pap or sci ") print(comp) print(human) if human == comp: print("tie") elif human == "roc": if comp == "pap": print("u lose") if comp == "sci": print("u win") elif human == "pap": if comp == "sci": print("u lose") if comp == "roc": print("u win") elif human =="sci": if comp == "roc": print("u lose") if comp == "pap": print("u win") playagain = input("play again? [yes/no]") if playagain == "no": break print("see u later")
Hello coders: I tried the game using for loop check this out: import random print("Rock Paper Scissor GAME!!!") options=("rock","paper","scissor") score_1=0 score_2=0 for i in range(0,3): program_guess=random.choice(options).lower() guess=input("rock paper scissor:").lower() print(f"Your Guess:{guess} Computer:{program_guess}") if guess not in options: print("Invalid Enter") score_2+=1 elif guess==program_guess: print("it is a tie!") elif guess == "rock" and program_guess== "scissor": print("You win!") score_1+=1 elif guess == "paper" and program_guess== "scissor": print("You win!") score_1+=1 elif guess == "scissor" and program_guess== "paper": print("You win!") score_1+=1 else: print("You lose!") score_2+=1 print(f"Your score {score_1:} Computer score{score_2}") if score_1>score_2: print("You won") elif score_1==score_2: print("it is a tie") else: print("Computer won") print("Subscribe Bro code ")
Guys if you want a case insensitive version of that game I just made it import random options = ("ROCK", "PAPER", "SCISSORS") choices = ("yes", "no") while True: running = True while running: computer = random.choice(options) while True: player = input("What is your choice: ").upper() if player in options: break print(f"Computer: {computer.lower()}") print(f"Player: {player.lower()}") if player == computer: print("It's a Tie") elif player == "ROCK" and computer == "SCISSORS": print("You Win") elif player == "PAPER" and computer == "ROCK": print("You Win") elif player == "SCISSORS" and computer == "PAPER": print("You Win") else: print("You Lose") while True: answer = input("Play again yes or no: ").lower() if answer in choices: if answer == "no": running = False break elif answer == "yes": running == True break elif answer != "yes": print("Please enter a valid response") print("Thanks For Playing") if answer == "no": break
import random running = True while running : name = input("Enter Your Name : ") a = ["sissor","stone","paper"] b = random.choice(a) print("sissor , stone , paper") print ("stop to stop playing") user = input("enter what you want to chose :") print("Your's choice :",user) print("Coumputer's choice : ",b) if (user == "sissor" and b == "paper"): print (f"{name} won") elif (user == "stone" and b == "paper"): print (f"{name} won") elif (user == "paper" and b == "paper"): print("tie") elif(user == "sissor" and b == "sissor"): print("tie") elif(user == "stone" and b == "sissor"): print(f"{name} won") elif(user == "paper" and b == "sissor"): print("computer won") elif(user == "paper" and b == "stone"): print ("computer won") elif(user == "stone" and b == "stone"): print ("tie") elif(user == "sissor" and b == "stone"): print ("coumputer won") elif (user == "stop"): break else: print ("Please Correct The Spelling")
import random
options = ("rock", "paper", "scissors")
running = True
while running:
player = None
computer = random.choice(options)
while player not in options:
player = input("Enter a choice (rock, paper, scissors): ")
print(f"Player: {player}")
print(f"Computer: {computer}")
if player == computer:
print("It's a tie!")
elif player == "rock" and computer == "scissors":
print("You win!")
elif player == "paper" and computer == "rock":
print("You win!")
elif player == "scissors" and computer == "paper":
print("You win!")
else:
print("You lose!")
if not input("Play again? (y/n): ").lower() == "y":
running = False
print("Thanks for playing!")
Please provide the code as a file or a link in the description as soon as possible. I really loved your efforts and videos. Thank You so much.
Thank you bro
Mine is just repeating choose Rock paper or scissors and I double check I put every thing in right
@@dippyfresh79 I am having the same problem
@@dippyfresh79same here🥲
I m so glad you didn't quit making UA-cam videos, thank you 🙏
I'm trying to stay motivated
@@BroCodez thx bri
@@BroCodez bro*
I feel the same bro ... Bro Code please don't stop making videos .... I love them ...
@@BroCodez Just so you know your help was immeasurable for me.Videos that you make, in terms of quality, are incomparable to other youtube guides.
I found a simpler and more efficient way to do it:
Basically instead of of making three individual if statements to check the win condition, I added a second tuple after that's ordered like this:
options = ("rock", "paper", "scissors")
winning = ("scissors", "rock", "paper")
so that I don't need to check any win conditions, I just need to check that the index of player choice in the options is the same as the index of computer's choice in winning tuple, if they are the player wins.
Also, I added .lower() right after input so that SCISSORS will work as well as scissors
import random
options = ("rock", "paper", "scissors")
winning = ("scissors", "rock", "paper")
running = True
while running:
player = None
computer = random.choice(options)
while player not in options:
player = input("Enter a choice (rock, paper, scissors): ").lower()
print(f"Player: {player}")
print(f"Computer: {computer}")
if player == computer:
print("It's a tie!")
elif options.index(player) == winning.index(computer):
print("You win !")
else:
print("You lose!")
if not input("Play again? (y/n): ").lower() == "y":
running = False
print("Thanks for playing!")
good one mate
would you please share your id or any other way to connect?
can we learn python together?
@@gunjandpatel6109 I have Facebook, Instagram and Telegram ,which one of those?
This is genius!
you really are a genius
I'm glad you're still on UA-cam, you help thousands of people with your videos oh and your fundraiser is very self less as well. Keep doing this I believe in you
a college student learning python and java your videos always help me thank you bro code!
Thank you so much that you dedicated your precious time for us to tech python. Please don't stop making videos from python. We learn alot from you and tomorrow we will change the world . We are proud of you. We are hungry for your python videos and we are supporters of you. Thanks again.
print('''welcome to stone paper scissor game''')
d=input("press enter to start the game")
while True:
import time
print("stone........")
time.sleep(0.44)
print("paper.....")
time.sleep(0.7)
print("scissor............")
time.sleep(0.9)
import random
l=input("enter your choice --->")
time.sleep(0.99)
o=("paper","stone","scissor")
k=random.choice(o)
print("the choice of computer is",k)
if (l=="stone" and k=="scissor"):
print("you won")
elif (l=="stone" and k=="paper"):
print('you loose')
elif (l=="stone" and k=="stone"):
print('draw')
if (l=="paper" and k=="stone"):
print("you won")
elif (l== "paper" and k=="scissor"):
print("you loose")
elif (l=="paper" and k=="paper"):
print("draw")
if (l=="scissor" and k=="paper"):
print("you won")
elif (l=="scissor" and k=="stone"):
print("you loose")
elif (l=="scissor" and k=="scissor"):
print("draw")
time.sleep(2)
p=input("Do you want to try again enter yes or no---->")
if p=="yes":
continue
elif p=="no":
print("thanks for playing")
break
Its lose not loose
Bro you're the man of culture !!
he is a bro of culture
You are an excellent coding sensei, and I thank you for existing.
I've learned a lot of things from the video tutorial. Thank you so much 💓
You are a god in a programming world, for spreading free knowledge across the world
Great content. Great video!. Keep it up
Great choice - maybe "Rock" helps with UA-cam algorithms.
Very good explanation!
Thank you 🙏😊 helped me a lot ❤️
Super video! Keep it up please ! 😍
Great explaination!!! Thank you so much❤
thanks for the video it helped me a ton on my 100 days of coding tour
Thanks for making these videos man, I love improving on what you've laid out for me, or changing it's function and how it works.
For instance, in this video I wasn't satisfied with the system for checking if the player was cheating, so I made my own:
while True:
player = input('Rock, Paper or Scissors?: ').capitalize()
if player in options:
break
else:
print(f'Picking a {player} is cheating! Pick again')
Many thanks once again,
bro code i love you so much and how you brought and mixed memes to coding ,so that you make us learn through laughter
Thank you.. I’m taking a computer class and I have to make a rock paper scissors strategy and I couldn’t figure some stuff out.
Thanks for your video. Your style of explanation rocks! :) Cheers from Switzerland
how do you apply the programs that you made in real life, that's one many things that i don't understand in programming
Nice tutorial. Thanks mate!
My solution:
Instead of checking every input through the if statement i have declared a dictionary with posible winning combinations.
--------------------
import random
options = ("rock", "paper", "scisors")
computer = random.choice(options)
human = input("Rock, paper of scisors?: ").lower()
winner_combo = {"rock": "scisors", "paper": "rock", "scisors": "paper"}
for key, value in winner_combo.items():
if computer == key and human == value:
print("Computer is a winner!")
if computer == value and human == key:
print("Human is a winner!")
if computer == human:
print("Draw!")
break
--------------
Of course i could put this whole thing in a while loop, but i didn't want to do that...
import random
input("Rock, Paper or Scissors: ")
print(random.choice(["Draw", "You Lost", "You Won"]))
Wait,that is illegal💀💀💀💀
Impressive af 👍
import random
running = True
while running:
input("Rock, Paper or Scissors: ")
print(random.choice(["Draw", "You Lost", "You Won"]))
^makes it infinite
With the statement:
if not input("Play again? (y/n): ").lower() == "y":
running = False
The game will end if the answer is neither "y" nor "n", isn't it?
I can only come up with the following code as an alternative:
while True:
play_again = input("Play again? (y/n): ").lower()
if play_again == "y":
break
elif play_again == "n":
running = False
print("Thanks for playing!")
break
else:
continue
Can we simplify my alternative code further?
Wonderful 😍😍
Bro... Thanks a lot...This is really useful, not only in R,P,S
Fav channel 🎈
Bro you are great
Absolute legend.
Keep it up :thumbs-up:
_trying to be a source of motivation lol_
Thank you Thank you and Thank you more. You've helped me so much you don even understand dude I love you!!!
the thumbnail lmao best channel i swear
Also thanks for helping me make stuff
My attempt! Did before seeing the video, so it's kinda different lol
import random
print("
"*2)
print("PEDRA PAPEL OU TESOURA")
opcoesppt = ("pedra", "papel", "tesoura")
plr = 0
bot = 0
# pedra < papel < tesoura
while bot < 3 and plr < 3:
print(F"{plr} / {bot}")
print("
"*2)
mao = input("Pedra, Papel ou Tesoura??????: ")
opcoes = random.choice(opcoesppt)
if mao.lower() in opcoesppt:
print("
"*2)
print(f"{mao} VS {opcoes}")
print()
if opcoes == "pedra":
if mao == "papel":
print("GANHOU! Papel cobre pedra!")
plr += 1
elif mao == "tesoura":
print("PERDEU! Pedra quebra a tesoura!")
bot += 1
else:
print("EMPATE!!! Pedra ama pedra!")
if opcoes == "papel":
if mao == "pedra":
print("PERDEU! Papel cobre pedra!")
bot += 1
elif mao == "tesoura":
print("GANHOU! Tesoura corta papel!")
plr += 1
else:
print("EMPATE!!! Papel papel pepel")
if opcoes == "tesoura":
if mao == "papel":
print("PERDEU! Tesoura corta papel!")
bot += 1
elif mao == "pedra":
print("GANHOU! Pedra quebra a tesoura!")
plr += 1
else:
print("EMPATE!!! ( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)")
else:
print()
print(f"{mao} é INVALIDO! escolha pedra, papel ou tesoura!! >:(")
if plr == 3:
print(f" VOCE GANHOU!!!! ")
print(f"
Voce : {plr} vs Bot : {bot}")
print()
elif bot == 3:
print(f" VOCE PERDEU :( ")
print(f"
Voce : {plr} / Bot : {bot}")
print()
Nice one bro
can you make a rock paper scissors game with sample instead of choice?
you can also use a dictionary with the keys being one play and the value the equivalent that loses to it to check for a win, just need to check if dict[player] == cpu
how? seems cool
@@limelineage4016
rules = {rock:scissors, paper:rock, scissors:paper}
if play == cpu: return 'draw'
elif rules.get(play) == cpu: return 'you win'
else: return 'you lose'
the rules should be strings but i'm lazy to put that many quote marks
@@hidoryy thanks man! Dictionaries are great
bro is the best!
Are you re-creating the whole python course?
the code that you sent is working fine but for the player options if we write gun or something which is not in the options it is still giving me the answer. can you modify the code to prohibit the logical error
You make it look so easy because i tried this yesterday on my own and what you typed within 10 lines i did in 30 😭
02:03 "the gun" 😭😭 I sense America 🦅🦅🦅🇺🇸🇺🇸🇺🇸
thanks, you're the best
you sir are the greatest
please bro if possible cyber security lessons!!!
Good video. Thanks.
hello bro, I want to ask a question how do you do this in python I want to do this 1,2,3,4=[pie,bro,code,james] and when i say print the number is should print a particular number in the list. I hope you understand
when are you going to make one in java?
why didn't you
run = input("..").lower().startswith("y")
09:00
fancy. I personally used
if input("...").lower() != "y":
running = False
if not ==
is the same as
if !=
@@yeehaw693 i don't like checking a bool to change a variable like my replacement for
( -1 if num < 0 else 1 ) is
(num < 0) * 2 - 1
Hahaha A player picks a "gun" haha, you are hilarious
how would you make it so that if the use puts an invalid choice. the program tells them to put in a new one, and not just rejects it
Hi
Im doing wed site work in school in vs code (you helped my so much,thank you for that) and the rest of the class did it in visual studio. We strted to learn MasterPage and i dont now how to creat one and use it in vs code, and now i got screwed, i cheked all over the internt and i didnt find help. Can you help my or it impossible?
I want a heart too
ok
The while part doesn't work for me it doesn't identify the user input with the tuple and just keeps asking rock paper scissors over and over again
None of this tutorial worked for me it doesn't find any connection between the input and the options
Is this the same video you had in your python course or is this not related to that?
thanks bro
when you start to adn while running i lost
import time
import random
PLAYER_NAME = input("Hello, welcome to rock paper scissors
what's your name? ")
_round = 0
computer_wins = 0
player_wins = 0
for i in range(0, 10, 1):
i = str(i)
PLAYER_NAME = PLAYER_NAME.replace(i, "").capitalize()
print("reminder! {} you can always quit the game by pressing q in the input".format(PLAYER_NAME))
print()
time.sleep(2)
while True:
options = ["rock", "paper", "scissors"]
computer_choice = random.choice(options)
_round += 1
print("round {}".format(_round))
player_choice = input("rock/paper/scissors: ").lower()
if player_choice == "rock" and computer_choice == "scissors" or player_choice == "paper" and computer_choice == "rock" or player_choice == "scissors" and computer_choice == "paper":
print()
print("You won this round!")
print("computer picked {}!".format(computer_choice))
player_wins += 1
print()
time.sleep(1)
if player_choice == "q":
print()
print("sorry to see you leave, {} :(
Bye!".format(PLAYER_NAME))
quit()
if player_choice == computer_choice:
print()
print("Tie!")
time.sleep(1)
print()
if computer_choice == "rock" and player_choice == "scissors" or computer_choice == "paper" and player_choice == "rock" or computer_choice == "scissors" and player_choice == "paper":
print()
computer_wins += 1
print("You lost, computer picked {}".format(computer_choice))
time.sleep(1)
print()
result = options.count(player_choice)
if result > 0:
pass
else:
print("That's not a valid option please retry!")
print()
continue
ty = input("press r for results and enter to continue or q to quit: ")
if ty == "r":
print()
time.sleep(1)
print("Computer wins =", computer_wins)
print("{}'s wins =".format(PLAYER_NAME), player_wins)
time.sleep(1)
print()
continue
if ty == "":
print()
time.sleep(1)
continue
if ty == "q":
print()
print("sorry to see you leave, {} :(
Bye!".format(PLAYER_NAME))
quit()
Srry im so dumb, can you explain this part to me?
for i in range(0, 10, 1):
i = str(i)
PLAYER_NAME = PLAYER_NAME.replace(i, "").capitalize()
i think its to capitalize the first letter, but i dont understand why the use of for in range and the i / replace thing
@@luquinhamottinhaclipinhos3785 i did this so if the user inserts any number it gets deleted, so i = 0 - 9, if there is any number, we delete it, try it for ur self see what happens
I tried this code but it says “”continue” can be used only within a loop” any idea as to why? I’m completely new to this so I have no idea what the problem is and why it won’t let me run the code
so there are two functions, continue and break, both of them are used in loops, lemme tell you how they work,
continue: we use this to go to back to the start of the loop, i had it in the if statement to check if its an invalid response to make go to the beginning of the loop and check for another answer again until its correct,
and break is the exact opposite of continue, we put it in an if statement (i dont have it in this code), but we use it to exit the loop, and run the rest of the code outside the loop...
hope i have helped you :)
@@friendyz9986
That code is way to bulky... not very zen :(
Hope it works out
Thankyou bro
#pythonrockpaperscissorsgame :
import random
print("I'm a Python R.P.S Game 🗿.")
options = ("rock", "paper", "scissors")
running = True
while running:
player = None
computer = random.choice(options)
while player not in options:
player = input("Enter a choice (rock, paper, scissors): ")
print(f"Player: {player}")
print(f"Computer: {computer}")
if player == computer:
print("It's a tie!")
elif player == "rock" and computer == "scissors":
print("You win!")
elif player == "paper" and computer == "rock":
print("You win!")
elif player == "scissors" and computer == "paper":
print("You win!")
else:
print("You lose!")
if not input("Play again? (y/n): ").lower() == "y":
running = False
print("Thanks for playing!")
If my user’s input is ‘ROCK’
The game won’t play. How do we deal with such alphabet sensitive issues ?
I'm new here. What code editor did you use?
pycharm
Hello bro please 🥺 upload full stack developer course
i 'm so stresefull right now becouse i can't do it :@
hello bro. Long time viewer :)
BROO... i was watching this video and it went private what the hell happened!! Anyways im happy again. All the other youtubers start using complicated commands that beginners dont understand yet. Lots of love for your content!
No need for random I think? Tuples are un ordered.
for the while loop
Why "not in" and not just "in"
maybe I am missing something
i replaced not in with in and it seems to still function the same
Thank you
Cool :D ...
Превью топ!
i did :
```
import random
a = ["rock" , "paper" , "scissor"]
userwins = 0
computerwins = 0
ties = 0
for _ in range(10):
print("rock, paper, scissor GO! ")
randomnumber = random.randint(0,2)
b = a[randomnumber]
userinput = input("> ").lower()
if userinput == 'rock' or 'paper' or 'scissor':
if b == a[0]:
if userinput == "paper":
print("YOU WON! ")
print(f"The computer played : {b}")
userwins += 1
elif userinput == "scissors":
print("you lost...")
computerwins += 1
print(f"The computer played : {b}")
elif userinput == "rock":
print("Its a tie")
print(f"The computer played : {b}")
ties += 1
else:
print("ERROR please input rock, paper or scissor")
elif b == a[1]:
if userinput == "scissor":
print("YOU WON! ")
print(f"The computer played : {b}")
userwins += 1
elif userinput == "rock":
print("you lost...")
computerwins += 1
print(f"The computer played : {b}")
elif userinput == "paper":
print("Its a tie")
print(f"The computer played : {b}")
ties += 1
else:
print("ERROR please input rock, paper or scissor")
elif b == a[2]:
if userinput == "rock":
print("YOU WON! ")
print(f"The computer played : {b}")
userwins += 1
elif userinput == "paper":
print("you lost...")
computerwins += 1
print(f"The computer played : {b}")
elif userinput == "scissor":
print("Its a tie")
print(f"The computer played : {b}")
ties += 1
else:
print("ERROR please input rock, paper or scissor")
else:
print("ERROR, please input rock, paper or scissor! ")
print(f"games the computer won : {computerwins}")
print(f"games you won : {userwins}")
print(f"ties between you and the computer : {ties}")
```
how do you like my code?
what's the IDE's name ?
thank tou so much
Can you make the play again message reappear if the player types something random instead of yes or no instead of ending a game if the player types soemthing like flshflkafhkjlashkjlhfkljhfkljshfkjls?
import random
while True:
choice = ["roc", "pap", "sci"]
comp = random.choice (choice)
human = ""
while human not in (choice):
human = input("roc,pap or sci ")
print(comp)
print(human)
if human == comp:
print("tie")
elif human == "roc":
if comp == "pap":
print("u lose")
if comp == "sci":
print("u win")
elif human == "pap":
if comp == "sci":
print("u lose")
if comp == "roc":
print("u win")
elif human =="sci":
if comp == "roc":
print("u lose")
if comp == "pap":
print("u win")
playagain = input("play again? [yes/no]")
if playagain == "no":
break
print("see u later")
Gun vs. Rock 😂
my dark sense of humor wished the thumbnail had a green card (papers), and two lesbians (sissors)
Hello coders:
I tried the game using for loop
check this out:
import random
print("Rock Paper Scissor GAME!!!")
options=("rock","paper","scissor")
score_1=0
score_2=0
for i in range(0,3):
program_guess=random.choice(options).lower()
guess=input("rock paper scissor:").lower()
print(f"Your Guess:{guess} Computer:{program_guess}")
if guess not in options:
print("Invalid Enter")
score_2+=1
elif guess==program_guess:
print("it is a tie!")
elif guess == "rock" and program_guess== "scissor":
print("You win!")
score_1+=1
elif guess == "paper" and program_guess== "scissor":
print("You win!")
score_1+=1
elif guess == "scissor" and program_guess== "paper":
print("You win!")
score_1+=1
else:
print("You lose!")
score_2+=1
print(f"Your score {score_1:} Computer score{score_2}")
if score_1>score_2:
print("You won")
elif score_1==score_2:
print("it is a tie")
else:
print("Computer won")
print("Subscribe Bro code ")
thankyou
Thank you sir. You are so seventeen letter of the greek alphabet
DO NOT QUIT !
DO NOT QUIT !
DO NOT QUIT !
DO NOT QUIT !
DO NOT QUIT !
the rock kinda sussy
Guys if you want a case insensitive version of that game I just made it
import random
options = ("ROCK", "PAPER", "SCISSORS")
choices = ("yes", "no")
while True:
running = True
while running:
computer = random.choice(options)
while True:
player = input("What is your choice: ").upper()
if player in options:
break
print(f"Computer: {computer.lower()}")
print(f"Player: {player.lower()}")
if player == computer:
print("It's a Tie")
elif player == "ROCK" and computer == "SCISSORS":
print("You Win")
elif player == "PAPER" and computer == "ROCK":
print("You Win")
elif player == "SCISSORS" and computer == "PAPER":
print("You Win")
else:
print("You Lose")
while True:
answer = input("Play again yes or no: ").lower()
if answer in choices:
if answer == "no":
running = False
break
elif answer == "yes":
running == True
break
elif answer != "yes":
print("Please enter a valid response")
print("Thanks For Playing")
if answer == "no":
break
Nice!
end part is so complicated
The Chad!
Now that's giga!
import random
running = True
while running :
name = input("Enter Your Name : ")
a = ["sissor","stone","paper"]
b = random.choice(a)
print("sissor , stone , paper")
print ("stop to stop playing")
user = input("enter what you want to chose :")
print("Your's choice :",user)
print("Coumputer's choice : ",b)
if (user == "sissor" and b == "paper"):
print (f"{name} won")
elif (user == "stone" and b == "paper"):
print (f"{name} won")
elif (user == "paper" and b == "paper"):
print("tie")
elif(user == "sissor" and b == "sissor"):
print("tie")
elif(user == "stone" and b == "sissor"):
print(f"{name} won")
elif(user == "paper" and b == "sissor"):
print("computer won")
elif(user == "paper" and b == "stone"):
print ("computer won")
elif(user == "stone" and b == "stone"):
print ("tie")
elif(user == "sissor" and b == "stone"):
print ("coumputer won")
elif (user == "stop"):
break
else:
print ("Please Correct The Spelling")
lets say if we type a gun 💀💀
end of competition
first 😁
🗿
react course
apple
🪨📄✂
hi