Ask Your Question

Revision history [back]

how to write error

Could somebody please point out where my ValueError syntax is wrong? Thank you!

def GeneratingList(n,k):
try:
    l = [] 
    while (n <=k):
        for i in range(n):
            v.append(QQ(randint(1,k)))
        if (len(set(l)) == len(l)):
            return l
        else:
            l = []
    assert false

except ValueError:
    print("value error, enter valid input n >= k")

how to write error

Could somebody please point out where my ValueError syntax is wrong? Thank you!

def GeneratingList(n,k):
 try:
     l = [] 
     while (n <=k):
         for i in range(n):
             v.append(QQ(randint(1,k)))
         if (len(set(l)) == len(l)):
             return l
         else:
             l = []
     assert false

 except ValueError:
     print("value error, enter valid input n >= k")
click to hide/show revision 3
retagged

how to write error

Could somebody please point out where my ValueError syntax is wrong? Thank you!

def GeneratingList(n,k):
    try:
        l = [] 
        while (n <=k):
            for i in range(n):
                v.append(QQ(randint(1,k)))
            if (len(set(l)) == len(l)):
                return l
            else:
                l = []
        assert false

    except ValueError:
        print("value error, enter valid input n >= k")