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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:01:21+00:00 2026-06-14T03:01:21+00:00

In programming, I’m writing a code that the user chooses a solid, and then

  • 0

In programming, I’m writing a code that the user chooses a solid, and then it calculates the volume and surface area. But instead of choosing directly, I give the user the option to ask for extra information on the solid, if they enter the number then ‘show’ (for example ‘1 show’). They can keep asking until a solid is chosen, so i used a while loop.

The loop isn’t working. If the condition with the loop isn’t valid, it still goes into it and loops and doesn’t let me get out. Please help. It’s pretty simple I think. I have tried to do integer and string conversions, without it helping.

#11/07/12 
#A program that asks user for input and calculates SA and Volume of a chosen solid

print "Which solid would you like to calculate?"    
print "  "      
print "1. Tetrahedron"          
print "2. Dodecahedron"           
print "3. Cone"                 
print "4. Sphere"                        
print "5. Icosahedron"                    
print '  '                        
print "If you want extra information on the solid, enter the solid's number and then add show. Example: 1 show"                   
print "If not, just enter the number"                       
choice = raw_input('----->')                             

#Where asks if user wants extra information on the solids, loops until solid is chosen             
while choice != '1' or choice != '2' or choice != '3' or choice != '4' or choice != '5':      
    if choice == "1 show":     
        print "A tetrahedron is composed of four congruent triangle faces. "     
    if choice =='2 show':      
        print "A dodecahedron is a polyhedron composed of 12 pentagonal faces. "      
    if choice == '3 show':       
        print 'A cone is a geometric solid that tapers smoothly from a circular base to an   apex. '          
    if choice == '4 show':          
        print "A sphere is a perfectly round circle. "            
    if choice == '5 show':
        print 'An icosahedron is a regular polyhedron with 20 congruent equilateral triangular faces'        
    choice = raw_input('Your new choice: ')              

if choice == 1: # Tetradedron               
    tetraside = raw_input("What is the length of your solid's side? ")               
    tetrabaseA = ((3 ** (1/2)) / 4) * tetraside**2                
    tetraheight = 9 * ((6 ** (1/2)) / 3) * tetraside                  
    tetraSA = 4 * tetrabaseA                
    tetraV = (1 / 3) * tetrabaseA * tetraheight                  
  • 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-14T03:01:22+00:00Added an answer on June 14, 2026 at 3:01 am

    Your while condition is wrong. Think about it: even if choice equals '1', the condition choice != '2' will be true, so the whole condition will always be satisfied.

    You need something like

    while choice not in {'1', '2', ...}:
    

    or

    while choice not in set(map(str, range(1, 6))): # a fancier version
    

    or just change all or to and in your condition.

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

Sidebar

Related Questions

Programming is learned by writing programs. But code reading is said to be another
Programming In Scala explains that tuples' _N numbers are one-based, instead of zero-based, because
Many programming languages require a special user-written function that marks the begin of the
Programming language: Java Ok, so I want to have a BufferedImage that keeps rotating
Programming language books usually explain that value types are created on the stack, and
Programming Environment: Visual Studio 2010 Programming Language: VB.NET I have a tabbed web-browser that
Programming novice here. I'm trying to allow a user to enter their name, firstName
Programming in a sense is easy. But bugs are something which always makes more
Kochan- Programming in objective-C. Can't understand two lines of code. (marked as comments) XYPoint.h
(programming in iPhone objective-C) I have a class level NSString* that I create, add

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.