+ 2

How it works?

def balik(st): if st != "": balik(st[1:]) print(st[0]) balik("rad")

17th Jun 2019, 8:44 AM
Christian Raditya Restanto
Christian Raditya Restanto - avatar
3 Respostas
+ 4
If an empty string is envoked with the function call of “balik("") nothing will happen as only strings will be processed but not empty strings.
17th Jun 2019, 11:03 AM
Lothar
Lothar - avatar
+ 4
christian, again: if an empty string is given as argument to function balik this is happening: if st != "": ->means if st is not empty so if statement will not execute and program is terminated regularly. code after if statement will be executed if string is not empty. result is : d a r check it out: https://code.sololearn.com/cz2X9mb4A58T/?ref=app
17th Jun 2019, 1:48 PM
Lothar
Lothar - avatar
+ 1
Lothar maybe my statement gone wrong, i mean how it works after an empty string called. You know this code will be executing by this way rad ad d "" -> empty string I know the output was d a r But what happen after empty strings? Hehe
17th Jun 2019, 11:13 AM
Christian Raditya Restanto
Christian Raditya Restanto - avatar