I am making a text based russian roulette game in Python, but I am not nearly finished, as one can see just by looking at my code:
#!/usr/bin/env python
print("The maximum number of bullets is 3")
bulletcounter = input("How many bullets do you want your gun to have?")
print(bulletcounter, "bullets")
paname = input("Enter Player 1's Name: ")
pbname = input("Enter Player 2's Name: ")
print(paname.capitalize(), "Vs.", pbname.capitalize())
if bulletcounter == 1:
bulletcount = 0
print(bulletcount)
bulletaloc = random.randint(1, 6)
while bulletaloc != bulletcount:
bulletcount += 1
For some reason, even if someone enters 1 into bulletcounter, it doesn’t trigger the if statement: if bulletcounter == 1. How do I make it trigger the if statement?
Use
raw_inputfor yourpanameandpbnamevariables. Be sure toimport randomat the top of your file. It would also be better to useint(raw_input("How many..."))forbulletcounter, too, I think, thaninput, since this can be used to evaluate any arbitrary python code.Also, it would be worth checking to see which version of Python you are using, when you invoke it using the
envcommand. If, at the command line, you run:and are getting “Python 2.x.y” instead of Python 3, and you are expecting to be using Python 3, consider changing that first line to call your Python 3 interpreter instead. The recommendations noted above assume you are using Python 2.