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
26
13
142
18.2K
Sergei Kotov
Sergei Kotov@kotov_dev·
Answer: d. None of the above The trick: "radar " has trailing space! › "radar ".split('a') → ['r', 'd', 'r '] › Last element is 'r ' (with space) For beginners: split() vs split('a'): › split() splits by whitespace (removes spaces) › split('a') uses exact separator (keeps spaces)
English
0
0
31
1.3K
Premakumar Thevathasan (Prem Iyer)
Premakumar Thevathasan (Prem Iyer)@KumarT00623760·
@PythonPr Python , name = "radar" print(name.split('a')) Code output ['r', 'd', 'r'] Answer is a. [’r’, ’d’, ’r’] For More Reference =>>
Premakumar Thevathasan (Prem Iyer) tweet media
English
0
0
0
748
Slinxs
Slinxs@JSlinxsx·
@PythonPr The output is: ['r', 'd', 'r '] ✅ Correct answer: (d). None of the above.
English
0
0
0
210
#!/usr/bin 🇮🇳
#!/usr/bin 🇮🇳@iamjogi·
@PythonPr d. None of the above. Option a is close but misses the trailing space in original string.
English
0
0
0
336
Vern
Vern@FCACF17·
@PythonPr None of the above 'syntax error'
English
0
0
0
153
Moises
Moises@moises_mr1·
@PythonPr The correct answer is a. ['r', 'd', 'r'].
English
0
0
0
155
Paylaş