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()
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/
Comments
Leave a comment