There are three codes. In first case the string breaks, in second case I am getting 'none' and for the third please see and run the code. https://code.sololearn.com/cxEzhE2L0d50/?ref=app
4/19/2021 5:52:44 AM
Aman Kumar4 Answers
New Answer`list.extend (iterable)` goes through `iterable` and appends every value in it to the end of the `list`. But it does not return any value, so it is defaulted to None.
fruit = ("apple") # a string fruit = ("apple",) # a tuple with one string. Notice the comma If you extend <car> by <fruit>, where <fruit> is a string, you append the characters from the string into <car>. If you extend <car> by <fruit>, where <fruit> is a tuple, you append the contents of the tuple into <car>.
Try to change the value for <fruit>, from ("apple") to ("apple",) and run the code again. You will notice the difference. But this time print <car> rather than <s> in the second code example.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message