【问题标题】:The question will be related to python which is basicThe question will be related to python which is basic
【发布时间】:2022-12-27 21:57:35
【问题描述】:

How to print reverse of the string?

I wanted to get all my test cases get solve but it showed runtime error at the end of submission.

【问题讨论】:

标签: python while-loop


【解决方案1】:

Thanks for asking the question : Let us assume the string is s="hello world" Then the statament s[::-1] will print the reverse of the string s as 'dlrow olleh'

【讨论】:

    【解决方案2】:

    def reverse(s): str = "" for i in s: str = i + str return str

    s = "Geeksforgeeks"

    print("The original string is : ", end="") print(s)

    print("The reversed string(using loops) is : ", end="") print(reverse(s))

    【讨论】:

    • You just copy/pasted the solution from Geeksforgeeks, even without the explanation!
    猜你喜欢
    • 1970-01-01
    • 2022-12-27
    • 2023-03-06
    • 1970-01-01
    • 2022-12-02
    • 2022-11-16
    • 2012-02-03
    • 2022-11-20
    • 2016-08-15
    相关资源
    最近更新 更多