+ 3

Why the type of positional argument comes different?

In first case it comes as list and in the second case it comes as tuple https://code.sololearn.com/cgSHi9Z7Mto7/?ref=app

6th Apr 2020, 10:46 AM
Utsav Singh
Utsav Singh - avatar
6 odpowiedzi
+ 2
HonFu but how we connect with him?
6th Apr 2020, 11:43 AM
Utsav Singh
Utsav Singh - avatar
+ 2
When you unpack a generator to a variable (what you do first with your variable 'd') you create a list (however you cannot 'append' anything to a tupple wich is imutable). When you append something to a list, you add an item to the end of the actual targeted list... so the list is always a list ^^ When you unpack arguments, python engine know you're another context, and specification have defined that arguments are passed as tuple (because it's logical: there's no need to have a mutable list here).
6th Apr 2020, 11:48 AM
visph
visph - avatar
+ 2
visph i understood thank you😊 You are guru sir😇
6th Apr 2020, 11:52 AM
Utsav Singh
Utsav Singh - avatar
+ 1
I doubt there's a deeper meaning. It's probably just how it was defined. str.split gives list, str.partition gives tuple. Why? We'll probably have to ask Guido.
6th Apr 2020, 11:24 AM
HonFu
HonFu - avatar
+ 1
Guido is the Python creator / guru ;(
6th Apr 2020, 11:40 AM
visph
visph - avatar