Q:

How do i use a variable that is defined inside of a function, outside of a function?

Here is my function:
def playNovice(marbles):
        import random
        rand = random.randint(1,(0.5*marbles))
        print('Computer takes: ', rand)

a = rand + rand
print(a)

I want to reuse the variable rand. I have a feeling it might be: 
global rand

I did try that but it didn't work, so i assume i used it wrong or its wrong all together.

A:

use return to give values back to the caller:
import random

def playNovice(marbles):
    rand = random.randint(1,(0.5*marbles))
    print('Computer takes: ', rand)
    return rand

rand = playNovice(6)
a = rand + rand
print(a)

