Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Python-Quizzes | Python String Quiz | Question 12

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

My Personal Notes arrow_drop_up
Last Updated : 18 Sep, 2020
Like Article
Save Article
Similar Reads