Python Forum
Beginner Needs Help To Get On The Right Track
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beginner Needs Help To Get On The Right Track
#1
I have an intro lab assignment, due today naturally, that I'm unable to get started. We were taught the "while" repetition structures but I don't know how to do this 2 player war game. It's a mess but here's what I have and would greatly appreciate any suggestions to get me on the right track. Thanks!
#description: generate a simulated version of the card game "War"

#two player game; will need to enter each player's name
#computer will generate a random number between 1-13
#the player with the highest number gets a point
#if both players get the same number, it's a draw
#first player to get to 10 points wins

import random

#initialize variables
player_one = str
player_two = str
player_one_draw = 0
player_two_draw = 0
player_one_draw = 0
player_two_draw = 0
player_one_score = 0
player_two_score = 0

player_one_draw = random.randint(1,13)
player_two_draw = random.randint(1,13) 

#ask for player names
player_one = str(input("Enter Player one name:"))
player_two = str(input("Enter Player one name:"))

#while neither player has 10 points
while player_one_score <10:
    player_one_score = str(input(player_one,"'s random number is",player_one_draw))
    player_two_score = str(input(player_two,"'s random number is",player_two_draw))
    if player_one_draw > player_two_draw:
        elif player_two_score > player_one_score:
            player_two_score = +1
            elif player_one_draw == player_two_draw:
                print("Both numbers were equal")
        if score ==10:
            print(player_one,"'s score is:",player_one_score)
            print(player_two,"'s score is:",player_two_score)
        

    player_one_score = player_one_score + 1

print(player_one,"'s score is",player_one_score)
print(player_two,"'s score is",player_two_score)
Reply


Messages In This Thread
Beginner Needs Help To Get On The Right Track - by gmom316 - Oct-09-2019, 02:44 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020