title: Why does this Python code show me a "TypeError: 'int' object is not iterable" after executing without any problems?
body: <p>My Code works just fine, but there is always an error at the end after everything was executed. And since I am a beginner I do not know why xD. Would be really cool if someone could help, I am just feeling really stupid right now xD.
  Thanks a lot in advance (:
  Here is also the complete Error message it shows:</p>
  <p>Your cards: [8, 9], current score: 17</p>
  <p>Computer's first card: 5</p>
  <p>Type 'y' to get another card, type 'n' to pass:y</p>
  <p>Your cards: [8, 9, 3], current score: 20</p>
  <p>Computer's first card: 5</p>
  <p>Type 'y' to get another card, type 'n' to pass:y</p>
  <p>Your cards: [8, 9, 3, 9], current score: 29</p>
  <p>Computer's first card: 5</p>
  <p>Your final hand: [8, 9, 3, 9], final score: 29</p>
  <p>Computer's final hand: [5, 3], final score: 8</p>
  <p>You went over. You lose </p>
  <pre><code>Traceback (most recent call last): 
  
    File &quot;main.py&quot;, line 120, in &lt;module&gt;
      game()
    File &quot;main.py&quot;, line 108, in game
      checks_who_wins(total_score_player, added_cards_value(cards_computer)) 
    File &quot;main.py&quot;, line 68, in checks_who_wins
      is_blackjack(added_cards_value_player, added_cards_value_computer)
    File &quot;main.py&quot;, line 47, in is_blackjack
      if added_cards_value(list_name_player) == 21:
    File &quot;main.py&quot;, line 43, in added_cards_value
      list_add = sum(list_name)
  TypeError: 'int' object is not iterable
  
  
  
  
  from art import logo 
  import random
  from replit import clear
  
  
  def eleven_card(cards_list_porc):
      a = random.randint(0,12)
      if a == 11:
          b = 21 - added_cards_value(cards_list_porc) 
          return b 
      return a
  
  def added_cards_value(list_name):
      # &quot;&quot;&quot;Calculate and adds every element of the list&quot;&quot;&quot;
      # list_add = 0
      # for x in range(0,len(list_name) ):
      #     list_add += list_name[x] 
      list_add = sum(list_name)
      return list_add
  
  def is_blackjack(list_name_player, list_name_computer):
      if added_cards_value(list_name_player) == 21:
          print(&quot;Win with a Blackjack &quot;)
          return &quot;a&quot;
      if added_cards_value(list_name_computer) == 21:
          print(&quot;Lose, opponent has Blackjack &quot;)
          return &quot;a&quot;
  
  def checks_who_wins(added_cards_value_player, added_cards_value_computer):
      if added_cards_value_player &lt; 21 and added_cards_value_computer &lt; 21:
          if added_cards_value_player &gt; added_cards_value_computer:
              print(&quot;You win &quot;) 
          if added_cards_value_player &lt; added_cards_value_computer:
              print(&quot;You lose &quot;)
          if added_cards_value_player == added_cards_value_computer:
              print(&quot;Draw &quot;)
      if added_cards_value_player &gt; 21:
          print(&quot;You went over. You lose &quot;)
      if added_cards_value_computer &gt; 21:
          print(&quot;Opponent went over. You win &quot;)
      if added_cards_value_player == added_cards_value_computer:
              print(&quot;Draw &quot;)
      is_blackjack(added_cards_value_player, added_cards_value_computer)
  
  def end_program(cards_player, cards_computer):
      print(f&quot;Your final hand: {cards_player}, final score: {added_cards_value(cards_player)} &quot;)
      print(f&quot;Computer's final hand: {cards_computer}, final score: {added_cards_value(cards_computer)} &quot;)
      y = False
  
  cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
  def game():
      play_decision = input(&quot;Do you want to play a game of Blackjack? Type 'y' or 'n': &quot;)
      if play_decision == &quot;n&quot;:
          return
      if play_decision == &quot;y&quot;:
          clear()
          print(logo)
  
          cards_computer = []
          for x in range (1,3):
              cards_computer.append(cards[random.randint(0,12)])
          cards_player = []
          for x in range (1,3):
              cards_player.append(cards[random.randint(0,12)])
          total_score_player = added_cards_value(cards_player)
          print(f&quot;Your cards: {cards_player}, current score: {total_score_player}&quot;)
          print(f&quot;Computer's first card: {cards_computer[0]}&quot;)
          if is_blackjack(cards_player, cards_computer) == &quot;a&quot;:
              game()
              return
          goes_on = input(&quot;Type 'y' to get another card, type 'n' to pass:&quot;)
          y = True
  
          while y == True:
              if goes_on == &quot;y&quot;:
                  cards_player.append(cards[eleven_card(cards_player)])
                  total_score_player = added_cards_value(cards_player)
                  print(f&quot;Your cards: {cards_player}, current score: {total_score_player}&quot;)
                  print(f&quot;Computer's first card: {cards_computer[0]}&quot;)
                  is_blackjack(cards_player, cards_computer)
                  if total_score_player &gt; 21: 
                      end_program(cards_player, cards_computer)
                      checks_who_wins(total_score_player, added_cards_value(cards_computer)) 
              if goes_on == &quot;n&quot;:
                  while added_cards_value(cards_computer) &lt; 20:
                      cards_computer.append(cards[eleven_card(cards_computer)])
                  end_program(cards_player, cards_computer)
                  checks_who_wins(total_score_player, sum(cards_computer))  
              if total_score_player &lt; 21 and goes_on == &quot;y&quot;:
                  goes_on = input(&quot;Type 'y' to get another card, type 'n' to pass:&quot;)
              else:  
                  y = False
          game()
  
  game()
  </code></pre>