Python Exercise 024: Number of digits and reverse print

Source: Internet
Author: User

"python exercise 024" gives a positive integer not more than 5 digits, requires: First, it is a number of digits, second, in reverse order to print out the figures.

----------------------------------------------

This problem if not recursive, it is too simple!!! On the code:

str = input (' Enter a positive integer not more than 5 bits: ') print (' This number is the number of%s bits, in reverse order%s. '% (len (str), str[::-1]))

The output results are as follows:

Please enter a positive integer with no more than 5 bits: 45931
The number is 5 digits, and the reverse is 13954.

It's so simple. Is it really necessary to write a recursive function? ...... Well, I know it's just a training, but I'm leaned now, and I'll update the recursive function tomorrow ... zzz

++++++++++++++++++++++++++++++++++++++

Source: Programming Language Introduction Classic 100 Cases "Python Edition"

Python Exercise 024: Number of digits and reverse print

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.