简体   繁体   中英

Python return variable defined with raw_input

i wonder how to pass some variable through functions with return in python, if one function starts with raw_input like this:

def function1():
    a = raw_input("Type something: ")
    return a

def function2():
    b = function1()       #i want b to get value of a 

When i try this and try to print "b" it just shows me again "Type something: " and again and again

You need to call function2

def function1():
    a = raw_input("Type something: ")
    return a

def function2():
    b = function1()
    print b
function2()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM