My question is how do i call the variable Neotile from the main function into the Neo() function and then redefine it and return it back into the main function at the begging of the while loop so it is redefined?

from p2lib import *
from string import *

def main():
    humantile = 0
    Neotile = 0
    
    
    print "Welcome to the teleportation game"
    humanplayer = raw_input("Please enter a user name: ")
    print "Ok let's play", humanplayer
    while (human != 51) or (Neo != 51):
        rolls = rollDice(2, 6)
        print "You rolled a", rolls
        humanmove = input("Which die do you want to use on yourself? ")
        if humanmove == rolls[0]:
            humantile = humantile + humanmove
            opposite = lower(raw_input("Enter the name of the player you wish to move: "))
            if (opposite == "neo"):
                Neotile = Neotile + rolls[1]
        elif humanmove == rolls[1]:
            humantile = humantile + humanmove
             opposite = lower(raw_input("Enter the name of the player you wish to move: "))
            if (opposite == "neo"):
                Neotile = Neotile + rolls[0]

##-----------------------------------------------------------------------------
            print "Neo's turn"
            print 
        



def Neo():
     rolls = rollDice(2, 6)
     if rolls[0] > rolls[1]:
         Neomove = rolls[0]
         Neotile =

Here's a simple example:

def funcA():
   var = 1
   print var
   var = funcB(var)
   print var

def funcB(var): #var could be named anything you want
    var = var + 25
    return var

funcA()

This will print (I hope, didn't test):

1
26

EDIT: Just to make this clear, funcB could be defined like these and everything would function the same:

def funcB(var123):
    var123 += 25
    return var123
def funcB(variable):
    return variable+25
This article has been dead for over six months. Start a new discussion instead.