Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Pythonic Solution for reverse_string #256

Closed
anthonyattard opened this issue Jul 24, 2019 · 3 comments
Closed

Issue with Pythonic Solution for reverse_string #256

anthonyattard opened this issue Jul 24, 2019 · 3 comments

Comments

@anthonyattard
Copy link

The following solution does not work:

class ReverseStringAlt(object):

    def reverse_string_alt(string):
        if string:
            return string[::-1]
        return string

    def reverse_string_alt2(string):
        if string:
            return ''.join(reversed(string))
        return string
@ghost
Copy link

ghost commented Sep 29, 2019

class ReverseStringAlt(object):
def reverse_string_alt(self,string):
if string:
return string[::-1]
return string

a=ReverseStringAlt()
s=input()
k=a.reverse_string_alt(s)
print(k)

@anthonyattard
Copy link
Author

@Harshavika is my solution correct?

@rizveeredwan
Copy link

@anthonyattard , this is your code which I just changed a little bit to run which gives correct answer.
https://ideone.com/Tm5EE0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants