Question: For my practice work in Python, I have to create a function that uses a string parameter and returns a list that contains the string

For my practice work in Python, I have to create a function that uses a string parameter and returns a list that contains the string and returns is as true or false, though it needs to return true if that string has the correct format as a US phone number. I was able to do this with a simple one digit number using this:

num = input("Enter a number: ") if num.isdigit() and int(num) < 10 and int(num) > 0: print("The number entered is positive and under 10.") else: print("Something else was entered.")

Then with this I would have to create a main function that tests the previous function. I would need to initialize a list to empty, then ask the user to enter a phone number and call the function. From each phone number entered and the boolean value it returns from the first function needs to be stored in a list of lists. The list is supposed to look something along the lines of this:

[ [121-111-1111, True], [22-2322-22, False], etc. ]

And the last thing is to know how to format this such as a table with alignments and proper headings, such as this:

Phone Number Valid =============================================== 123-456-7890 True 11-11-11 False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!