How would you define a recursive function that asks the user for a string and prints it from the outside in. For example, 123456 would print as 162534. Any help would be appreciated.
jozz3 0 Light Poster
Recommended Answers
Jump to PostWhat do you have so far?
To start you are going index the first and last in the method.
str = '123456' str[0] #index the first str[-1:]#index the last
Then just build a simple recursive method to solve.
Post your code if you have any …
Jump to PostI know there is a better way to write that last line,
but I'm too lazy to look into itI think you could convert to a list and just pass a pair of index counters, but it is more than I want to do as well.
All 5 Replies
tbone2sk 14 Junior Poster in Training
jcao219 18 Posting Pro in Training
jcao219 18 Posting Pro in Training
woooee 814 Nearly a Posting Maven
jozz3 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.