title: "Play" is not defined - Pylance (reportUndefinedVariable)
body: <p>I am just starting Python and am having a problem with calling classes. I am using Visual Studio Code, might be the problem? I have looked up the error but could not find anything. I have all of my experience with Java and think I might be getting some stuff mixed up. Any help would be greatly appreciated!</p>
  <pre><code>print(&quot;Lets play a game!&quot;)
  
  dotheywantotplay = input(&quot;Do you want to play Rock-Paper-Scissors? (y or n) &quot;)
  
  if dotheywantotplay == &quot;y&quot;:
  
      player1 = input('Enter first players name: ')
      player2 = input('Enter second players name: ')
  
      personchoice1 = input(&quot;What move will you do? [\&quot;Rock\&quot;, \&quot;Paper\&quot;, \&quot;Scissors\&quot;]&quot;)
  
      personchoice2 = input(&quot;What move will you do? [\&quot;Rock\&quot;, \&quot;Paper\&quot;, \&quot;Scissors\&quot;]&quot;)
  
      Play(personchoice1,personchoice2) // The error looks like its this line
  
  else:
      print(&quot;I am so sad now :-(&quot;)
      exit()
  
  
  class Play:
      def __init__(player1, player2):
  
          if player1 == player2:
                  print(&quot;Tie!&quot;)
          elif player1 == &quot;Rock&quot;:
              if player2 == &quot;Paper&quot;:
                  print(&quot;You lose!&quot;, player2, &quot;covers&quot;, player1)
              else:
                  print(&quot;You win!&quot;, player1, &quot;smashes&quot;, player2)
          elif player1 == &quot;Paper&quot;:
              if player2 == &quot;Scissors&quot;:
                  print(&quot;You lose!&quot;, player2, &quot;cut&quot;, player1)
              else:
                  print(&quot;You win!&quot;, player1, &quot;covers&quot;, player2)
          elif player1 == &quot;Scissors&quot;:
              if player2 == &quot;Rock&quot;:
                  print(&quot;You lose...&quot;, player2, &quot;smashes&quot;, player1)
              else:
                  print(&quot;You win!&quot;, player1, &quot;cut&quot;, player2)
          else:
              print(&quot;That's not a valid play. Check your spelling!&quot;)
  </code></pre>
  <p><em>Above</em> was the original question for future reference. <em>Below</em> is the solution. Python is different that Java in that, one has to define classes before they are referenced. This means the classes need to be at the top of your python file. Hope this helps some other Java nerd out there trying to write programs in Python...
  <a href="https://i.stack.imgur.com/fJXzB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fJXzB.png" alt="Program working" /></a></p>
  <pre><code>    print(&quot;Lets play a game!&quot;)
      
      dotheywantotplay = input(&quot;Do you want to play Rock-Paper-Scissors? (y or n) &quot;)
      
  
  
  
  
  print(&quot;Lets play a game!&quot;)
  
  dotheywantotplay = input(&quot;Do you want to play Rock-Paper-Scissors? (y or n) &quot;)
  
  
  
  class Play:
      def __init__(self, player1, player2, name1, name2 ):
  
          self.player1 = player1
          self.player2 = player2
          self.name1 = name1
          self.name2 = name2
  
  
          if player1 == player2:
                  print(&quot;Tie!&quot;)
          elif player1 == &quot;Rock&quot;:
              if player2 == &quot;Paper&quot;:
                  print(&quot;You Win &quot;, name2,&quot;!&quot;)
                  print(player2, &quot;covers&quot;, player1)
              else:
                  print(&quot;You Win &quot;, name1,&quot;!&quot;)
                  print(player1, &quot;smashes&quot;, player2)
          elif player1 == &quot;Paper&quot;:
              if player2 == &quot;Scissors&quot;:
                  print(&quot;You Win &quot;, name2,&quot;!&quot;)
                  print(player2, &quot;cut&quot;, player1)
              else:
                  print(&quot;You Win &quot;, name1,&quot;!&quot;)
                  print(player1, &quot;covers&quot;, player2)
          elif player1 == &quot;Scissors&quot;:
              if player2 == &quot;Rock&quot;:
                  print(&quot;You Win &quot;, name2,&quot;!&quot;)
                  print(player2, &quot;smashes&quot;, player1)
              else:
                  print(&quot;You Win &quot;, name1,&quot;!&quot;)
                  print(player1, &quot;cut&quot;, player2)
          else:
              print(&quot;That's not a valid play. Check your spelling!&quot;)
  
  
  if dotheywantotplay == &quot;y&quot;:
  
      player1 = input('Enter first players name: ')
      player2 = input('Enter second players name: ')
  
      personchoice1 = input(&quot;What move will you do? \&quot;Rock\&quot;, \&quot;Paper\&quot;, \&quot;Scissors\&quot;  &quot;)
      personchoice2 = input(&quot;What move will you do? \&quot;Rock\&quot;, \&quot;Paper\&quot;, \&quot;Scissors\&quot;  &quot;)
  
      Play(personchoice1,personchoice2, player1, player2)
  
  else:
      print(&quot;I am sad now :-(&quot;)
      exit()
  </code></pre>