Python-Quizzes | Python String Quiz | Question 12

Question 12: What is the output of the following program?

filter_none

edit
close

play_arrow

link
brightness_4
code

var1 = 'Geeks'
  
print(var1[:4] + 'for' + 'Geeks'

chevron_right


(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
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.