Hello!
I have this simple funcion

def newUser():
	print 'Choose a username?'
	Username = raw_input('> ')

The variable 'Username' has to be used by other functions. How can I do it?
Cheers!

Dani

you can do:

global Username
Username = raw_input('> ')

in the function, and 'Username' will be available for the rest of the program to use

Using global is not a good soultion at all,learn to give argument at return value out functions.
A simple example.

def newUser():    
    Username = raw_input('Choose a username? ')
    return Username


def reg_user(newUser):
    '''Make 3 users an save to a list'''
    l = []
    for i in range(3):
        l.append(newUser())        
    return l   
    
if __name__ == '__main__':     
    print reg_user(newUser)

'''-->Out
Choose a username? Tom
Choose a username? Paul
Choose a username? Hans
['Tom', 'Paul', 'Hans']
'''

yeah dont use global, it could be very problematic

def newUser():    
    return raw_input('Choose a username? ')

user = newUser()
# do something to user.
This question has already been answered. Start a new discussion instead.