Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
23
8
74
8.6K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Correct answer: D → Error The code shown is: print(".join(x) The string quote isn’t closed, so Python raises a SyntaxError before execution.
English
1
0
7
640
Sergei Kotov
Sergei Kotov@kotov_dev·
Answer: B) a.b.c Step by step: › ".".join(x) uses "." as the separator › It goes BETWEEN elements, not around them › "a" + "." + "b" + "." + "c" = "a.b.c" For beginners: Why .join() over loops? A loop like s += '.' + el adds a dot at the END too. Use .join() when you need separators only BETWEEN items!
English
0
0
3
348
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr The answer is C: abc. Why is this the answer? The code uses the .join() method, which is a powerful way to concatenate (combine) elements of a list into a single string. Here is the breakdown: The List: x = ["a", "b", "c"] is a list containing three separate string elements.
English
1
0
1
268
フリーザンス
フリーザンス@otakunoojisan12·
@PythonPr 現代でこれを書いてるエンジニアがいたらエディタのインストールからやり直しやな
日本語
0
0
1
166
Jay
Jay@learnaiwthme·
Correct answer: C – abc Explanation: "".join(x) joins all elements of the list using an empty string as the separator. x = ["a", "b", "c"] The separator is "" (nothing between items) So Python concatenates the elements directly: "a" + "" + "b" + "" + "c" → "abc" That is why the output is: abc
English
0
0
0
270
Ehshanulla
Ehshanulla@Ehshanulla·
@PythonPr There are two errors: Missing closing quote for the string "." Missing closing parenthesis for print() Because of this, Python raises a SyntaxError. output= Error
English
0
0
0
168
ANKIT 𓃱
ANKIT 𓃱@A9kitSingh·
@PythonPr Answer is C) abc "".join(x) concatenates all elements with no separator, producing abc.
English
0
0
0
223
Ranjan
Ranjan@Ranjanrgdev·
@PythonPr What is the right answer I'm confused between C and D
English
0
0
0
8
laso
laso@lasitolas·
@PythonPr C...Look at the list join method
English
0
0
0
15
Fórmula (β)
Fórmula (β)@sayanfitness·
@PythonPr una lista que quiere imprimir la función pero le falto el parentesis, error de sintaxis= Error
Español
0
0
0
268
Paylaş