Nov-12-2018, 02:35 AM
Also note that if a value is not 300 or less, then you already know it's over 300:
But as I implied and stulis clarified, generating 1-900 and then shrinking it down to 1-3 is overkill. Unless that is part of the assignment?
Have you done dictionaries yet? That's the best way to handle determining who won rock-paper-scissors in my experience.
def getvalue(cpu): if cpu <= 300: value = 1 elif cpu <= 600: value = 2 else: value = 3 return valueOf course, since it is even ranges, you could just divide (
random.randint(1, 900) // 3 + 1
).But as I implied and stulis clarified, generating 1-900 and then shrinking it down to 1-3 is overkill. Unless that is part of the assignment?
Have you done dictionaries yet? That's the best way to handle determining who won rock-paper-scissors in my experience.
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