Jul-24-2020, 12:20 AM
HI team,
This is my first post since I started learning Python now and came to know about this forum. Hence I reached out here to get clarifications.
I need to reverse a string and print it, and I have written a code. But it is not complete and prints a different answer when I give the input. I think the loop (i = i + 1) is not executed properly and hence its printing only the alphabhet 'c'. I am not sure of what I am missing here.
May I kindly request this forum to help me fix this issue. I am thankful to you for the effort you have taken for reading thi post.
ragav
This is my first post since I started learning Python now and came to know about this forum. Hence I reached out here to get clarifications.
I need to reverse a string and print it, and I have written a code. But it is not complete and prints a different answer when I give the input. I think the loop (i = i + 1) is not executed properly and hence its printing only the alphabhet 'c'. I am not sure of what I am missing here.
May I kindly request this forum to help me fix this issue. I am thankful to you for the effort you have taken for reading thi post.
def reverse(s): '''(str) -> str Return the reverse of s. >>> reverse('abc') 'cba' ''' str_change = '' i = len(s) - 1 while i >= 0: str_change = str_change + s[i] i = i + 1 return resultThanks,
ragav