Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started