Question related to True and reverse function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Question related to True and reverse function

I don't understand following coding. printName('Olga', 'Puchmajerova') printName('Olga', 'Puchmajerova', True) printName('Olga', 'Puchmajerova', reverse=True) >>> Olga Puchmajerova Puchmajerova, Olga Puchmajerova, Olga My question is,, 1) Why there is comma in second, Third result is it because of True? 2) Why sequence is reversed is it also because of True? 3) Why they put reverse=True just instead of reverse? I want to know all detail from this code. Thank you :)

13th Jun 2020, 12:31 AM
beanibeanibean
beanibeanibean - avatar
2 Answers
+ 1
You skipped something... the actual defining of the printName function, like the most important part that has all the logic of why the output looks like that. The function most likely has 3 parameters. firstname, lastname, and reversed. In python, you can make default values for each parameter if you want or not. def printName(fname, lname, reverse=False): See how i made the reverse parameter equal to False? False is that parameters default value. Notice how in the second call, the last parameter is True. That makes reverse equal to true. (the third example is exactly the same)
13th Jun 2020, 9:40 AM
Slick
Slick - avatar
+ 2
Thank you for detail explanation 😆
13th Jun 2020, 10:07 AM
beanibeanibean
beanibeanibean - avatar