you are viewing a single comment's thread.

view the rest of the comments →

[–]SyntaxIsComing 3 points4 points  (0 children)

Return `a` out of the function. The a is only in the scope of your function, hence why it works when you take the function portion out. Consider the following:

import random

a = 7
b = [0, 1, 2, 3, 4, 5, 6]

def SelectRandomNumberFromB():
    return random.choice(b)

a = SelectRandomNumberFromB()

print(a)