Python-Quizzes | Python String Quiz | Question 12
Question 12: What is the output of the following program?
var1 = 'Geeks'
print (var1[: 4 ] + 'for' + 'Geeks' )
|
(A) GeeksforGeeks
(B) GeekforGeek
(C) GeekforGeeks
(D) GeekForGeeks
Answer: (C)
Explanation: Python provides a flexible way to update string in your code. Use square brackets and specify the index from where string has to be updated and use + operator to append the string. [x:y] operator is called Range Slice and gives the characters from the given range.
Quiz of this Question
Please comment below if you find anything wrong in the above post
Last Updated :
18 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...