Open In App
Related Articles

Python-Quizzes | Python List Quiz | Question 12

Improve Article
Improve
Save Article
Save
Like Article
Like

Question 12: Find the output of the following program: 

Python3




list = ['python', 'learning', '@', 'Geeks', 'for', 'Geeks']
print(list[0:6:2])


(A)

[‘python’, ‘@’, ‘for’]

(B)

[\’Geeks\’, \’Geeks\’, \’learning\’]

(C)

[\’python\’, \’learning\’, \’@\’, \’Geeks\’, \’for\’, \’Geeks\’]

(D)

[\’python\’, \’Geeks\’]


Answer: (A)

Explanation:

In python list slicing can also be done by using the syntax listName[x:y:z] where x means the initial index, y-1 defines the final index value and z specifies the step size. If anyone of the values among x, y, and z is missing the interpreter takes the default value.


Quiz of this Question
Please comment below if you find anything wrong in the above post

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 17 Sep, 2020
Like Article
Save Article
Previous
Next
Similar Reads