Given some data in a text file, the task is to scramble the text and output...

70.2K

Verified Solution

Question

Programming

Given some data in a text file, the task is to scramble the textand output in a separate text file. So, we need to write a Pythonprogram that reads a text file, scrambles the words in the file andwrites the output to a new text file.

Rules to be followed:

  • Words less than or equal to 3 characters need not bescrambled.
  • Don’t scramble first and last char, so Scrambling canbecome Srbmnacilg or Srbmnailcg orSnmbracilg, i.e. letters except first and last can bescrambled in any order.
  • Punctuation at the end of the word to be maintained as is i.e.“Surprising, ” could become “Spsirnirug, ” but not “Spsirn,irug”

Answer & Explanation Solved by verified expert
3.9 Ratings (502 Votes)
ANSWERI have provided the properly commentedand indented code so you can easily copy the code    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students