What will typing the following at the Python interpreter produce?
lang = list('Python') ; lang[:-4]
Explanation
String 'Python' will first be converted to a list representation ['P', 'y', 't', 'h', 'o', 'n'] and assigned to variable lang.
Syntax [:-4] means slicing a list and returning all of its contents except for last 4 elements.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Python quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes