Strings in functions


#1

Hi,
Can anybody help me to find out whats wrong with this.It showing in output Helloworld 2 times and not taking Waynesworld.

n = “Hello”

Your function here!

def string_function(s):
s=n+"world"
return s

print string_function(n)
print string_function(“Waynes”)


#2

What is n? It doesn’t exist, does it? You want to concatenate the “world” string literal with the incoming string that is in s.


#3

Actually, n is right over here:


@ppatel253gmail.com,

The reason why it’s not printing "Waynes" is also because you assigned it to your variable n, so now, our parameter s now contains the concatenated string: "Helloworld".


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.