Post

Python Developer
Python Developer@Python_Dv·
What will be the output? Write your answer in the comment section. ✅✅
Python Developer tweet media
English
21
10
119
13.6K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@Python_Dv Output C) [9, 7, 5, 3, 0] — slicing with step -2 picks every 2nd element from the end.
English
0
0
7
1.3K
The root of infinity
The root of infinity@parth_hirpara05·
@Python_Dv [::-2] means: start from the end move backwards take every 2nd element Ans---> A: [9, 7, 5, 3, 1]
English
0
0
1
504
Python Tech
Python Tech@PythonTech43716·
@Python_Dv C) is the correct answer. Here we are using concept of list slicing and [start:End:step_size] and step size is -2 so it reverse the list.
English
0
0
1
878
Jenny
Jenny@JennyTheDev·
@Python_Dv A: [9, 7, 5, 3, 1] [::-2] starts from the end and steps backward by 2. Also, naming your variable "list" is the real crime here. Somewhere a Python built-in is crying 😂
English
1
0
1
1K
claveprep
claveprep@claveprep·
Python slice notation can be tricky! Negative indexing counts from the end, so [-2:] gets the last two elements, and [:-2] excludes them. These fundamentals are crucial for data manipulation. Understanding Python's syntax deeply improves code efficiency and readability across projects.
English
0
0
0
307
Paylaş