Is this a bug or a feature in Python?

preview_player
Показать описание
Is this a bug or a feature in Python? Do you know the explanation?
NOTE: I intentionally missed a comma in line 4, and Python does implicit string concatenation!
Meaning, "three" "four" becomes "threefour"!!! Beware of this feature in Python!

~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

#Python #shorts
Рекомендации по теме
Комментарии
Автор

explanation:
adjacent string literals are implicitly concatenated.
on lines 4 and 5, the two strings "three" and "four" are concatenated into "threefour"

mohamedmohamedy
Автор

This guy is honestly just training us to spot errors when we have to fix our own code

dhruvray
Автор

yeah you forgot the comma after "three", so Python think that "three" and "four" is one element (and they both are concatenate)

KananHasanov-bkop
Автор

Missed a ", " so three and four concat. Lmao. I've done this so many times.

Magnymbus
Автор

I don't see an issue here. Between "three" and "four" there is no comma, thus concatenating them into one string. This will result in having four strings in the array.
This is intended behaviour for very large strings, so that one can break them into multiple lines.

Edit: I guess one could say: "It's not a bug. It's a feature. :)"

linusbrendel
Автор

line 3 and 4 are not separated they are one line therefore the answer is 4 if you put a comma after string "three" then the answer will be 5

bluvesta
Автор

IF a Junior run that code:
Python: "error at your brain"
Sênior:
Python: "Nothing wrong here"

maxmx
Автор

Explanation: “three” and “four” are treated as “three”+”four”
Therefore there really is 4 items

trucookieq
Автор

In between 3 and 4 you don't separate it with comma (, ) that's why it's considered as a one combined string ( "threefour")

upgradestudy
Автор

I'm laughing so hard, out of all the python jokes I've seen this was the funniest one I dont know why

CunningBard
Автор

I definitely think this should throw a compile time error. Its strange and unexpected behavior for most devs, even as someone who has been using python exclusively for the last two years, I spotted the missing comma but though its going to throw a syntax error, not implicitly concat them.

On the same note, people should watch our for additional commas (not only missing commas) as well as commas are what syntactically create tuples not round brackets. You might mistakenly create tuples if you place a comma by mistake somewhere.

fardinahsan
Автор

', ' is Missing after "three"
Which means "three"&"four" is a single element
Thats why len(a) = 4
✌️

prashantwarghude
Автор

If you want to see length of list equal to 5 you need to add a comma after the string « three »
Without a final comma, the string « Three » will be a literal that will be concatenated to the string « Four ».

alexander_adnan
Автор

He didn't put a comma to separate "three" and "four", thus they catenated to one and reported a list of 4 items 🚶‍♂️

ayushyadav
Автор

there is no comma between "three" and "four" so it is considered as a single string "threefour"

vaishnavikhandare
Автор

Comma after "three" and "four" be like "Mujhe andar to lo"😂.

dnbndu
Автор

The "three" and "four" concatenated in 1 line (miss the, in the end) so is correct.

dbfuentes
Автор

", " missing after "three"
Logical error detected

taranveersingh
Автор

there is also supposed to be a comma after three

carnavshorts
Автор

Там нет запятой после "three"
Значит "three"+ "four" это один элемент списка .
Это не баг :)

aqwex
welcome to shbcf.ru