Python please: Using the template code as a starting point, write a program that reads a string of letters as input and produces output that is either a number or an error message. The output number should equal the sum of the values assigned to the letters (defined below). The program should output the error message if the input contains any characters that are not defined below. The error message should read "Error: Input contains an invalid character. Valid input characters are A, E, J, O, T, Z, YY." Your template code creates a list of letters and assigns each letter a number value: Letter Number A 1 E 5 J 10 O 15 T 20 Z 26 YY 50

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python please:

Using the template code as a starting point, write a program that reads a string of letters as input and produces output that is either a number or an error message. The output number should equal the sum of the values assigned to the letters (defined below). The program should output the error message if the input contains any characters that are not defined below. The error message should read "Error: Input contains an invalid character. Valid input characters are A, E, J, O, T, Z, YY."

Your template code creates a list of letters and assigns each letter a number value:

Letter Number
A 1
E 5
J 10
O 15
T 20
Z 26
YY 50

NOTE 1: The final value in the list (YY) is a two-letter combination that must appear in full in order to be considered valid input.

NOTE 2: A space is not a valid input character.

HINT: You may use string[start:end] to parse the input string and extract the numeric integer for the "YY" combination.

Example 1: If the input is

TEA

the output should be

26

Example 2: If the input is

JOYY

output should be

75

Example 3: If the input is

JOY

the output should be

Error: Input contains an invalid character. Valid input characters are A, E, J, O, T, Z, YY.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education