Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3481132
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:25:03+00:00 2026-05-18T10:25:03+00:00

this is what Ii wrote so far but it is not the correct output

  • 0

this is what Ii wrote so far but it is not the correct output

def characters(char):
    numb=ord(char)
    while numb>ord('a'):
      print chr(numb),
        numb=numb-1

    return

I want the this output:

characters('h')
    g f e d c b a
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:25:03+00:00Added an answer on May 18, 2026 at 10:25 am

    Whenever you design a recursive function, the first thing you want to ask yourself is: how does the algorithm terminate? I.e., what’s the base case? In your example, the algorithm should stop printing characters after the letter ‘a’ is printed, so that’s your base case.

    Next, you have to ask how to get to the base case from your starting case. That’s pretty easy: you want to print the previous character until you reach the base case. (A character is essentially just an integer, so that means you want to subtract one from the character and print it as a string.)

    Putting that all together, I got:

    def print_reverse(ch):
        print ch,
        if ch > 'a':
            print_reverse(chr(ord(ch)-1))
        else:
            print   # New line
    
    print_reverse('h')
    

    (If you don’t know what the Python functions ord and chr do, look them up in the interactive interpreter using help(ord) and help(chr).)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this so far but I don't know how to write over the
I wrote this code for zoom in/out . it works but even with one
I wrote this infeasible oml by mistake while trying to do another thing. What's
I don't need to write this in jQuery but I'm not versed enough in
this code should take a char as an argument and print out that char
I am not even sure whether the title of my question is correct, but
This is as far as I've gotten. What code would I write to save
I wrote this as a simple dice game. It works as I want except
I wrote this code for zoom in / out and it suppesed to only
I wrote this short program which has a tiny GUI. Its supposed to allow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.