32.1k views
4 votes
What is an example of a situation in which you might use the append method? In what ways is the append method limited?

User Jacquelyn
by
3.7k points

1 Answer

6 votes

Answer:

In a Black jack game!

Step-by-step explanation:

while sum(player_cards) < 21:

action_taken = str(input("Hit or Stay? "))

if action_taken == "hit":

player_cards.append(random.randint(1, 11))

print("You now have a total of " + str(sum(player_cards)) + " from these cards ", player_cards)

In here we are using the append feature to add a "card" whenever they type in the word "hit". The append function is only used to add on to the line of code and not to replace it. Hope this helped!

User Nick Parker
by
3.9k points