Can anyone expalain me this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anyone expalain me this?

def h(*n): return (n) x=('solo') print(h(x)) why we use * in fun. parameter, output is tuple what is this ,why we use this and how we can use * like more.please tell me,i really need help to understand this topic.

30th Mar 2018, 4:03 PM
Maninder $ingh
Maninder $ingh - avatar
2 Answers
+ 8
When you precede the argument in the function definition with an asterisk, you tell it to accept an arbitrary number of arguments. You can then pass it one, two or any other number of arguments and it will deal with all of them. Just for convenience, they will be passed as a sequence, namely of a tuple type. https://docs.python.org/3.6/tutorial/controlflow.html#arbitrary-argument-lists
30th Mar 2018, 4:09 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
I find it watch this: https://youtu.be/gZB_ENJD34E
30th Mar 2018, 4:41 PM
Maninder $ingh
Maninder $ingh - avatar