Question

Complete the Python function to return the last n characters of a string s. If n is greater than the string's length, return the entire string. def get_last_n_chars(s,
n):     _________ # Line to complete

A return s[len(s)-n:]
B return s[-n:]
C return s.substring(len(s)-n)
D return s.slice(-n)
E return s[max(1, len(s)-n):]
Practice Next

Hey! Ask a query

🎓
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
  • 200 Questions with Detailed Solutions
  • Section-wise Coverage (GA, English, Quant & Reasoning)