empty_string = ''
string_1 = 'beta'
def sample(x):
empty_string = empty_string + 'alpha'
return x
why doesn’t:
empty_string = 'alpha'
i’m confused why empty_string is still empty after i add to it in the function
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
use
global empty_stringinside function, then only you can modify a global variable: