What happens if i index with 0 as a step? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What happens if i index with 0 as a step?

In list slicing, taking nums = [2, 4, 7, 8, 22, 54, 1, 0] as an example. when we try to print(nums[1:6:2]), the output is >>>[4, 8, 54] right.? now what if i try to print (nums[1:6:0] ), what happens and why, thanks!

30th Sep 2021, 6:30 AM
Jamil 🇺🇬 stark
Jamil 🇺🇬 stark - avatar
2 Answers
+ 3
Why not run the code and get the answer to your question?
30th Sep 2021, 7:31 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Unfortunately it just throws an error as list slice 0 is not viable
30th Sep 2021, 6:48 AM
Kamil Hamid
Kamil Hamid - avatar