+ 2

At fourth line what is diference between output=speak("shout") and output=speak(shout) ???

def shout(word): return word+"!" speak=shout output=speak("shout") print(output)

16th Sep 2017, 12:56 PM
emi
4 odpowiedzi
+ 4
'shout' would be a string so that would work fine and output "shout!". Using shout without quotations on the other hand would give an error as you have not made a variable with that name and is therefore non-existent.
16th Sep 2017, 1:05 PM
LynTon
LynTon - avatar
+ 1
thanks LP4 but after some study I thought that the problem is because of difference between types. shout without Quotation is function and It can't be add with "!" that is a string.
23rd Sep 2017, 2:26 PM
emi
+ 1
shout
31st Aug 2019, 10:21 AM
Mishal Mahmood
Mishal Mahmood - avatar
+ 1
speak, shout and output are all functions. Although functions are created differently than normal variables, they are the same as any other type of value. They can be assigned or reassigned to variables and then referenced by these names and then "shout" is the arguments , the input "shout" obey the pattern word +"!" since shout = speak = output, you can change the code with: def output(word): return word + "!" print(output("shout") shout!
14th Apr 2021, 8:23 AM
SILI ZHAO
SILI ZHAO - avatar