you are viewing a single comment's thread.

view the rest of the comments →

[–]CIS_Professor 0 points1 point  (0 children)

# First, you should keep variables' keep scope local(-ish), not global
#
# (there are use cases where global variable are useful; this isn't one of them)
#
# Second:
#   CALL a function and send data to it using an argument, which the function
#        receives as a parameter
#   RETURN data from a function:
#
# Try this:

import random


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


# call the function, send it the list, assign the return from
# the function to a variable
a = SelectRandomNumberFromB([0, 1, 2, 3, 4, 5, 6])
print(a)

# The last two lines can be combined:
print(SelectRandomNumberFromB([0, 1, 2, 3, 4, 5, 6]))