I'm trying to check 4 separate variables for the exact same strings using separate variables with similar names. An example is below. The print functions are also an example, they're not my final goal.
from random import randint
example1 = randint(1,3)
example2 = randint(1,3)
example3 = randint(1,3)
example4 = randint(1,3)
if example1 == 1:
print ("A")
elif example1 == 2:
print ("C")
else:
print ("M")
Can anyone suggest how I could repeat this area for all of the variables?
if example1 == 1:
print ("A")
elif example1 == 2:
print ("C")
else:
print ("M")
randint(str(1,3))gives a TypeError. What exactly are you trying to do there?randint(str(1,3))will throw an errorlen({example1,example2,example3,example4}) == 1?listor adict.