Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python, I'm trying to write code that converts one of those lettered telephone numbers (such as 555-GET-FOOD) to its corresponding numeric telephone number. I've

image text in transcribedimage text in transcribed

In Python, I'm trying to write code that converts one of those lettered telephone numbers (such as 555-GET-FOOD) to its corresponding numeric telephone number. I've attached my code and the result i get. I'm confused -- why aren't the letters being converted to the numbers I have in the loop? How would I fix this?

For example, 555-GET-FOOD should end up printing 555-438-3663

num-input ("Enter a telephone number in the format xxx-xxx-xXXX: split_num-num. split(-' new num- for ch in split num: if ch.upper) in 'ABC': elif ch.upperin 'DEF': elif ch.upperin 'GHI': elif ch.upperin 'JKL' elif ch.upper ) elif ch.upper) in 'PQRS elif ch.upper ) in 'TUV elif ch.upper ) in 'WXYZ ch= ' 2 ' ch= ' 3 ' 10 12 ch= ' 5' 14 15 16 17 18 19 20 21 n 'MNO' ch-7 ch-'8 ch= ' 9' new num+-ch 23 24 print (new_num)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago