Question
In this problem you should write a complete python program. Your program should accept a single string input from the user, which is supposed to
In this problem you should write a complete python program. Your program should accept a single string input from the user, which is supposed to be a location formatted as City, County, ST Where City is the name of a city, County is the name of the county that city is in, and ST is the two-letter US state acronym. The program you write needs to loop through this input string and do a bit of validation to see if it is formatted correctly. Your program should check whether or not the string has the following:
- Exactly 2 commas
- The two characters after the two commas must be empty spaces
- The last two letters are capitalized (you can use the s.isupper() function to check if a string s is capitalized)
If all of these conditions are met, the program should print Location formatted OK. If any are not met, it should print Location not formatted correctly. The only built-in strung function you are allowed to use are the upper and isupper functions. You may not use count, index, indexof, etc. You will want to use one or more if-statements, string indexing, and a while-loop.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started