Question

let a user enter the state abbreviation, the city name, and their establishment year. Some error...

let a user enter the state abbreviation, the city name, and their establishment year. Some error checking
and input conversion is required. For instance, 123 is not valid input for state; ca
is valid input for state, but store it as CA; AB123 is not valid input for city name;
SanTA moniCA is valid input for city name, but store is as Santa Monica;
-1987 is not valid input for year; abc is not valid input for year. You could also
set a range for the establishment year, such as 1500 to 2000. Make sure your
program does not crash on invalid input.
2. Replace the ListNode structure with a class

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#python 3.6

#defining class City

class City:
   def __init__(self):
       try:
           statename = input("Enter state")
           if(len(statename) = 2 and isalpha(statename)):
               self.state = statename.upper()
       except:
           print("State should be of 2 characters")
      
       try:
           cityname = input("Enter city name")      
           if(isalpha(cityname)):
               self.name = cityname
       except:
           print("City name shuld be alphabetic")  
      
       try:
           year = print("Enter establishment year")
           if(year > 1500 and year < 2000)
               self.estYear = year
       except:
           print("Establishment year should be between 1500 and 2000")4


#Creating an object

city1 = City()

Add a comment
Know the answer?
Add Answer to:
let a user enter the state abbreviation, the city name, and their establishment year. Some error...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ please! (1) Prompt the user to enter the name of the input file. The file...

    C++ please! (1) Prompt the user to enter the name of the input file. The file will contain a text on a single line. Store the text in a string. Output the string. Ex: Enter file name: input1.txt File content: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! (2) Implement a PrintMenu() function,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT