How To Fix Print Is Not Working In Python With The Random Lib
I am creating a rock, paper, scissor game i just try the random lib but this what happens
C:\Users\Timothy\Desktop>python app1.py 2 Please choose 1=Rock, 2=Paper, 3=Siccors2
and this is the code that I create
import random ai = (random.randint(1,3)) print(ai) play = input("Please choose 1=Rock, 2=Paper, 3=Siccors") if ai == play: print("Hello")
In Python 3, the
input() method returns a
play will be a string
ai will be an integer
"1" != 1, hence your code will not execute the statements inside the
play = input("Please choose 1=Rock, 2=Paper, 3=Siccors")
play = int(input("Please choose 1=Rock, 2=Paper, 3=Siccors"))
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module