May-07-2019, 04:38 PM
Trying to finish my game of war card game. I am currently on the final step and need to have it keep score.
Can someone please guide me on how to compare the position of 2 items from the same list? The further the item is to the left of the list or 0 is the one that gets the point. (or should at least).
Here is the code I currently have.
Can someone please guide me on how to compare the position of 2 items from the same list? The further the item is to the left of the list or 0 is the one that gets the point. (or should at least).
Here is the code I currently have.
import random def main(): totalCards = 52 playerOne = 0 playerTwo = 0 pOneScore = 0 pTwoScore = 0 deck = [] suit = [] totalList = [] deck = ["Ace","King","Queen","Jack",2,3,4,5,6,7,8,9,10] suit = ["of spades","of hearts","of clubs","of diamonds"] for num in deck: for suitType in suit: totalList.append(str(num) + ' ' + suitType) print("Welcome to war. Press any button to deal a hand.") while (totalCards > 0): input() print("Cards are being delt!") print() dealCard(totalList, playerOne, playerTwo) print() totalCards -= 2 print(totalCards, "cards remain in the deck.") print("Player one's score: ", pOneScore) print("Player two's score: ", pTwoScore) print("The game of war has ended!") print("The final score is: ") def dealCard(totalList, playerOne, playerTwo): playerOneSuit = "" playerTwoSuit = "" playerOne = random.choice(totalList) print("Player one: ",playerOne, playerOneSuit) totalList.remove(playerOne) playerTwo = random.choice(totalList) print("Player two: ",playerTwo, playerTwoSuit) totalList.remove(playerTwo) return totalList, playerOne, playerTwo main()