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 9054935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:48:57+00:00 2026-06-16T13:48:57+00:00

I havn’t been able to find a solution to this problem on the internet

  • 0

I havn’t been able to find a solution to this problem on the internet (maybe im not looking hard enough) but i can’t figure out how to make an input only take numbers. Im trying to get the input to go through some equations and the program brakes everytime i put a letter in the input. I was wondering if there was a way to detect if the input was a letter or number. I’ll show my program.

    Radius=input("What is the radius of the circle/sphere?")

    Areacircle=(int(Radius)**2)*3.14159265359
    Perimetercircle=2*3.14159265359*int(Radius)
    Permsphere=4*3.14159265359*(int(Radius)**2)
    Areasphere=(4/3)*3.14159265359*(int(Radius)**3)

    print("The radius' length was:",Radius)
    print("The surface area of each circle is:",Areacircle)
    print("The perimeter of the circle is:",Perimetercircle)
    print("The volume of the sphere would be:",Areasphere)
    print("The perimeter of the Sphere would be:",Permsphere)
  • 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-06-16T13:48:58+00:00Added an answer on June 16, 2026 at 1:48 pm

    As suggested in the comments, you can handle a ValueError when the conversion to int fails (and save doing this same conversion throughout the rest of your code).

    Radius = None
    while not Radius:
        unchecked_radius = input("What is the radius of the circle/sphere? ")
        try:
            Radius = int(unchecked_radius)
        except ValueError:
            print('"{}" is not an integer. Redo.'.format(unchecked_radius))
    

    I recommend reading the Python Tutorial section on Handling Exceptions, which has a very similar example.

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

Sidebar

Related Questions

I havn't been able to find the answer to this, and I hope theres
I have a issue I havn't yet been able to find a solution on.
My problem seem's trivial but I havn't found any good solution to this. First
I havn't been able to find an answer to this, and it may very
There's a bunch on this topic, but I havn't found an instance that applies
This is a really simple question but I havn't done c++ properly for years
Lots available on this subject but I havn't found anything that answers my question...
Perhaps this is a duplicate question, but I havn't found something by myself. Basically
been following posts on this site for a while and find them very helpful.
I've been searching for answers, but unfortunately still havn't found one the right one..

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.