*a, = "RealPython"
a with a trailing comma seems to be a list type, not a tuple
Good observation ‘GJ’, I think you are right.
Here to demonstrate.
>>> a = [‘Python, bytes’]
>>> type(a)
<class ‘list’>
>>> b, = ‘Python, bytes’
>>> type(b)
<class ‘list’>
>>> a == b
True
>>> a == tuple(b)
False
There may be some transferred confusion from a comma idiosyncracy as follows
>>> type((‘singleterm’,))
<class ‘tuple’>
>>> type((‘singleterm’))
<class ‘str’>
def sum(*args): # Returns a tuple values
Whereas,
my_list = [1, 2, 3, 4, 5]
a, *b, c = my_list
Here, *b
returns a list not a tuple? What am missing here. Please help.
list1 = [1,2,3]
list2 = [3,4,5]
merged_list1 = [*list1, *list2]
> whats difference with
merged_list2 = list1+list2
merged_list1 == merged_list2
> True
Become a Member to join the conversation.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4