Python random.randint(a,b) function is generating the same values on each successive row. Any ideas why?

Viewed 11
import random 

operations = ["Add", "Sub", "Mult", "Div","Log","Expo","Percent"]
interval = [1,2,3,4,5,6,7,8,9]

add, sub, mult, div, log, expo, percent = [[]], [[]], [[]], [[]], [[]],[[]],[[]]
mathOperations = [add,sub,mult,div,log,expo,percent]

def startGame():
    printData(mathOperations)


def printData(operations):
    for operation in operations:
        print(operation)
def getPrefs():
    print("For each operation please indicate the amount of non-zero integers before and after the operand(seperated by a comma of course). \n")
    for i in range(0,len(mathOperations)):
        numLeft = input("What is the leftNumSize you wish to select for the " + operations[i] + " operation?\n")
        numRight = input("What is the rightNumSize you wish to select for the " +  operations[i] + " operation?\n")
        mathOperations[i] = [[0]*int(numLeft)]*int(numRight)
        temp = mathOperations[i]
        for row in range(0,len(temp)):
            for col in range(0,len(temp[row])):
                temp[row][col] = random.choice(interval)
                
            
def printOperations():
    print("The current operations are \n")
    for operation in operations:
        print(operation)
def queryUser():
    choice = input("Would you like to remove any operations or is numOperations to your liking?\n")
    if(choice[0].lower() == 'y'):
        removedString = input("What operation would you like to remove?\n")
        for operation in operations:
            if(removedString.lower() == operation.lower()):
                operations.remove(operation)
        printOperations()
        queryUser()
    else:
        getPrefs()
        startGame()




printOperations()
queryUser()
0 Answers
Related