Hi! I'm a super noob just starting to learn python and programming in general. My problem is trying to verifiy a random number
but ending up with invalid syntax.
import random
heroAttack = random.randint (1, 10)
if heroAttack > 5
print (You hit!)
else:
print (You miss.)
I always get an invalid syntax at the number 5. Could somebody tell me what is wrong?
4 replies to this topic
Sponsor:
#2 Crossbones+ - Reputation: 3539
Posted 31 August 2012 - 10:12 PM
You need to end conditions by a colon (:). Also, I think you need "You hit!", "You miss." to be strings, but I could be wrong on this. Also you want to wrap Python code in code tags, because of indentation:
import random
heroAttack = random.randint (1, 10)
if heroAttack > 5:
print ("You hit!")
else:
print ("You miss.")






