way to reverse a string in Python | Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ต.ค. 2024

ความคิดเห็น • 4

  • @EshanTahir
    @EshanTahir ปีที่แล้ว +2

    Extra spaces not needed: print(name[::-1]) would work too.

  • @BunnyRabbit.
    @BunnyRabbit. ปีที่แล้ว

    on most exams we are prohibited from using slicing or any other build-in functions 😔

  • @valentinpetrov6775
    @valentinpetrov6775 ปีที่แล้ว

    string = "codewithsekar"
    rev_str = ""
    for i in range(len(string)-1, -1, -1):
    rev_str += string[i]
    print(rev_str)
    rakeshtiwedoc

  • @BlackneeedWasHere
    @BlackneeedWasHere ปีที่แล้ว

    oldname = ’codewithsekar’
    name = oldname[::-1]
    print(name)