Python problem

17 views
Skip to first unread message

Soumen Khatua

unread,
Dec 15, 2019, 9:55:28 AM12/15/19
to django...@googlegroups.com
Hi Folks,
I'm stucking in this problem from 5 hours but still I'm not bale to logic to solve this problem, Please help me guys to solve this problem:

Example:-
input: h123456ello
output: o123456lleh

input: th34isisast56ring3
output: gn34irtsasi56siht3

Thank you in advance.

regards,
Soumen

Chetan Ganji

unread,
Dec 15, 2019, 10:28:43 AM12/15/19
to django...@googlegroups.com
# input: h123456ello
# output: o123456lleh

# input: th34isisast56ring3
# output: gn34irtsasi56siht3


order = {}
characters = ""
input_string = "h123456ello"
# input_string = "th34isisast56ring3"
counter = 0 
output_string = ""


for index, character in enumerate(input_string): 
    order[index] = character 

for item in range(0len(input_string)):
    if input_string[item].isalpha():
        characters += input_string[item]

# reversing the string
characters = characters[::-1]

for index, item in enumerate(range(0len(input_string))) :
    if input_string[item].isalpha():
        order[index] = characters[counter]
        counter += 1

for index in range(0len(input_string)):
    output_string += order[index]

print()
print(input_string)
print(output_string)
print()




Regards,
Chetan Ganji
+91-900-483-4183


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6Wa8LqGGnqbsiKvYrBw6WQkBaqjm9b8Re65PM3zJr1rdkA%40mail.gmail.com.

Gil Obradors

unread,
Dec 15, 2019, 10:37:56 AM12/15/19
to django...@googlegroups.com
Chetan, you're a genius!

Missatge de Chetan Ganji <ganji....@gmail.com> del dia dg., 15 de des. 2019 a les 16:28:

Soumen Khatua

unread,
Dec 15, 2019, 11:20:42 AM12/15/19
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages