Sep-13-2019, 03:28 PM
You just use integer literals (without quotes) instead of string literals (with quotes):
cpu = randint(1, 3) ai = cpu if cpu == 1: ai = "r" elif cpu == 2: ai = "p" elif cpu == 3: ai = "s"But, note that random.choice will pick a random item out of a sequence, even a string. So all of the above code could be replaced with this one line:
ai = random.choice('rps')
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures