Answer to Question #293742 in Python for hsoxx01

Question #293742

def winnerRPS(me, you):

  if(me == you):

    return(0)

  if(me == "rock"):

    if(you == "scissor"):

      return(1)

    else:

      return(-1)

  if(me == "paper"):

    if(you == "rock"):

      return (1)

    else:

      return(-1)

  if(me == "scissor"):

    if(you == "paper"):

      return(1)

    else:

      return(-1)

  

   

def main():

  print(winnerRPS("rock", "paper"))

  print(winnerRPS("rock", "rock"))

  print(winnerRPS("paper", "scissor"))

  print(winnerRPS( "scissor", "paper" ) # now add your own to test it more...


if __name__ == "__main__":

  main()


Can't figure out what should go in : if __name__ == "__main__":

  main()



1
Expert's answer
2022-02-04T14:50:12-0500

The line you specified is responsible for launching the main function of the presented script. The if block specifies which function should run first. In this case, the main function is specified, which is the input function of the script. Follow the link for more detailed information:

https://www.freecodecamp.org/news/if-name-main-python-example/


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS