I'm an absolute amateur when it comes to any coding but I have been attempting to create a top trumps type program using Python. In the below code I have created player cards that are added to a list using a class. I am now attempting to randomly split the list (fullCardList) into two separate lists but having a lot of issues. Once the list has been split, I am aiming to compare a stat from each player but cannot seem to figure how to show the card's name/caps/goals. I hope this makes sense. Can anyone give me any advice?
class Player:
def __init__(self, name, caps, goals, trophies):
self.name = name
self.caps = caps
self.goals = goals
self.trophies = trophies
CardListOne = Player("Lionel Messi",102, 46, 26)
CardListTwo = Player("Ronaldo", 124, 55, 17)
CardListThree = Player("Mats Hummels", 39, 4, 8)
CardListFour = Player("Angel Di Maria", 65, 15, 10)
CardListFive = Player("Jason", 101,44,12)
CardsListSix = Player("Peter", 45,10,1)
fullCardList = [CardListOne.name, CardListOne.caps,CardListOne.goals,CardListOne.trophies],[CardListTwo.name,CardListTwo.caps,CardListTwo.goals,CardListTwo.trophies],[CardListThree.name, CardListThree.caps, CardListThree.goals, CardListThree.trophies], [CardListFour.name,CardListFour.caps,CardListFour.goals,CardListFour.trophies], [CardListFive.name,CardListFive.caps,CardListFive.goals,CardListFive.trophies]
global playersRandomSelection, computersRandomSelection
playersRandomSelection = []
playersRandomSelection = random.sample(fullCardList,3)
computersRandomSelection = []
computersRandomSelection = random.sample(fullCardList,3)
print("Players name selection: " + str(playersRandomSelection))
print("Computers random selection: " + str(computersRandomSelection))