Write a program that reads a task name on the first line of the input and then
carries out that task, reading further lines as the task requires. Every task keeps
reading until it meets its own terminal value, so these are jobs for a while loop
rather than a for loop.
Supported tasks
sum_until_0 — read integers, one per line, until 0 is read. Print their sum (the terminating 0 adds nothing).total_price — read lines of the form quantity price (two integers separated by a space) until the line END. Print the total bill, i.e. the sum of quantity * price over all the lines.only_ed_or_ing — read words, one per line, until the word STOP. Print every word that ends with ed or ing (or ED or ING), one per line, in the order read.reverse_sum_palindrome — read integers, one per line, until -1. For each positive n, add n to the number formed by reversing its digits; if that sum reads the same forwards and backwards, print n.double_string — read lines until an empty line is read. For each line, print it repeated twice with nothing in between.odd_char — read words, one per line, until a word that ends with a full stop .. For every word before that one, print the characters at the even indices (the 1st, 3rd, 5th … character) followed by a space, all on the same line.only_even_squares — read numbers, one per line, until the line NAN. Print the square of each number whose square is even, one per line.only_odd_lines — read lines until the line END. Treat everything read as a sequence of whitespace-separated words, keep the words at the even indices (0, 2, 4, …), and print them in reverse order, one per line.Input format
The first line is the task name. The lines after it are whatever that task consumes, ending with the terminal value described above.
Output format
Whatever the chosen task prints, as described above.
Write a complete program: read the input with input() and print the result with print().
Input
sum_until_0
5
7
-2
0
Output
10