-
September 28th, 2021, 06:02 AM
#1
Reverse String in Python
Hi I have recently joined the community here is my first doubt:
I was reading the python reverse string article and I understood the concept but I got stuck while implementing the same using loop.
Problem:
I wanna reverse a random string in a function using a loop,
I wouldn't use ".join(reversed(string)) or string[::-1] methods here.
Here is what my code looks like:
HTML Code:
def reverse(text):
while len(text) > 0:
print text[(len(text)) - 1],
del(text[(len(text)) - 1]
I am getting an invalid syntax on on del(text[(len(text)) - 1]
Any suggestion would be appricated.
Thank you.
-
September 28th, 2021, 10:42 AM
#2
Re: Reverse String in Python
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|