Problem with asteric(*) variable and type | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Problem with asteric(*) variable and type

When I write this code it shows error. a,*b='abcdef' print(*b,type(*b)) It throws a error that type() takes 1 or 3 argument. How to know the type of '*b' and can anyone give me a example of type() taking 3 arguments. What it actually mean?

25th Jun 2020, 10:57 AM
Mir Abir Hossain
Mir Abir Hossain - avatar
7 Answers
+ 4
You can do it like this: a,*b='abcdef' print(*b,type(b))
25th Jun 2020, 12:48 PM
Lothar
Lothar - avatar
+ 2
Thanks a lot. The article clears the confusions.
25th Jun 2020, 1:21 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
+ 1
https://docs.python.org/3/library/functions.html#type
25th Jun 2020, 11:33 AM
rodwynnejones
rodwynnejones - avatar
+ 1
thank you ^_^
25th Jun 2020, 12:16 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
+ 1
Thanks ^_^
25th Jun 2020, 1:10 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
+ 1
now it shows <class 'list'>
25th Jun 2020, 1:11 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
+ 1
I wanted to know the type of (*b)
25th Jun 2020, 1:14 PM
Mir Abir Hossain
Mir Abir Hossain - avatar