hamburger menu
All Coursesall course arrow
adda247
reward-icon
adda247
    arrow
    arrow
    arrow
    Which of the following Python syntax can be used to reverse a given string word?
    Question



    Which of the following Python syntax can be used to reverse a given string word?

    A.

    word[::-1]

    B.

    reversed(word)

    C.

    "".join(reversed(word))

    D.

    All of the above

    E.

    None of the above

    Correct option is D

    In Python, there are multiple ways to reverse a string:
    1. word[::-1]:
    · This uses slicing with a step of -1 to reverse the string.
    2. reversed(word):
    · This returns a reversed iterator, which can be converted to a string using "".join().
    3. "".join(reversed(word)):
    · This is another valid method that combines the reversed iterator into a single string.
    Important Key Points:
    1. Strings in Python are immutable, so reversing them does not modify the original string.
    2. The slicing method ([::-1]) is the most concise and widely used for reversing strings.
    3. Using reversed() with "".join() is more explicit but slightly longer.
    Knowledge Booster:
    · word.reverse(): This method is not valid for strings as it works only for mutable sequences like lists.
    · Strings can also be reversed using loops, but Python's built-in methods are preferred for simplicity and readability.

    Free Tests

    Free
    Must Attempt
    Video Solutions

    RBI Assistant Pre 2026 Full Mock Test -01

    languageIcon English
    • pdpQsnIcon100 Questions
    • pdpsheetsIcon100 Marks
    • timerIcon60 Mins
    languageIcon English
    Free
    Must Attempt
    Video Solutions

    RBI Asst Prelims 2026 : Reasoning Section Test 01

    languageIcon English
    • pdpQsnIcon35 Questions
    • pdpsheetsIcon35 Marks
    • timerIcon20 Mins
    languageIcon English
    Free
    Must Attempt
    Video Solutions

    RBI Asst Prelims 2026 : Quant Section Test 01

    languageIcon English
    • pdpQsnIcon35 Questions
    • pdpsheetsIcon35 Marks
    • timerIcon20 Mins
    languageIcon English
    test-prime-package

    Access ‘IBPS RRB SO IT Officer (Scale-II)’ Mock Tests with

    • 60000+ Mocks and Previous Year Papers
    • Unlimited Re-Attempts
    • Personalised Report Card
    • 500% Refund on Final Selection
    • Largest Community
    students-icon
    368k+ students have already unlocked exclusive benefits with Test Prime!
    Our Plans
    Monthsup-arrow