Question DSA-STR-0023
EasyWhat is the output of this code?
print('abc'[::-1])
- A.
Error
- B.
cba
- C.
Show answer and explanation
Answer: B
A slice with step −1 reverses the string.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Strings question
What is the output of this code?
print('abc'[::-1])
Error
cba
Answer: B
A slice with step −1 reverses the string.
bca
abc