Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that reads text from the user and reverses the order of every number that appears in the text. For example: Hello! The

Write a program that reads text from the user and reverses the order of every number that appears in the text. For example: Hello! The number is 17. will become Hello! The number is 71. To help with this problem, first write a function rev(text) that takes a string of text and returns the reverse. For example, rev("Oranges") would return "segnarO". You may create any additional function you need. You must create the rev function. Your program will ask for a string of text and reverse and number. A number is defined as any sequence of digits 0-9. Remember to use if name=="__main": so that ZyBooks can test your rev function. Here are two examples.

image text in transcribedimage text in transcribedThis is the code I have so far but this reverses the entire input instead of reversing only numbers:

print('Welcome to Digit Flipper') text = input('Enter Some Text: ') print('Revised String:') for char in range(len(text) - 1, -1, -1): print(text[char], end="")

Welcome to Digit Flipper Enter Some Text: Hello! The number is 17 Revised String: Hello! The number is 71

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

Modern Datalog Engines In Databases

Authors: Bas Ketsman ,Paraschos Koutris

1st Edition

1638280428, 978-1638280422

More Books

Students also viewed these Databases questions

Question

=+3. What public and objective does each tactic serve?

Answered: 1 week ago

Question

struggling to figure this out. please help ()()()

Answered: 1 week ago

Question

Evaluate three pros and three cons of e-prescribing

Answered: 1 week ago