Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called switcheroo that takes a word (Say w), two integers (Say i, j where i) as input and switches the characters at

image text in transcribed

Write a function called "switcheroo" that takes a word (Say w), two integers (Say i, j where i) as input and switches the characters at index 1, j of word w and display the result. Note: Steps of switcheroo function can be given as follows: def switcheroo (w, i, j): display an error message. i. substring! = the substring of w from start of the string to ii. subs trina2 = the substring of w from 1+1 to J-1 2. Otherwise, the last position before i. substrings = the substring of w from J+1 to the end of the string iv. Concatenate the substring in the order, substringl, character at index j, substring2, character at index i and substring3 and display the result. For example, switcheroo ("Cs104", 1, 3) displays the string "C01s4" and switcheroo ("Cs104", 3, 1) displays an error message. Save the script as "lab4_checkpoint1 py" in cs104lab4 folder

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

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

1. Explain why evaluation is important.

Answered: 1 week ago