Question

Write a function mirror(s) that takes as input a string s and returns a mirrored version...

  • Write a function mirror(s) that takes as input a string s and returns a mirrored version of s that is twice the length of the original string. For example:

    >>> mirror('bacon')
    result: 'baconnocab'
    
    >>> mirror('XYZ')
    result: 'XYZZYX'
    

    Hint: Use skip-slicing!

Homework Answers

Answer #1

def mirror(myStr):

#appening origianl string with reversed string will give mirro string

#sliing with -1 will give the reverse of string

return myStr+myStr[::-1]

print(mirror("bacon"))

print(mirror("XYZ"))

Note : Please follow the screen shot for the Indentation of the code

Note : If you like my answer please rate and help me it is very Imp for me

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a recursive method that takes as input a string s and returns a list containing...
Write a recursive method that takes as input a string s and returns a list containing all the anagrams of the string s. An anagram is a word formed by rearranging the letters of a different word. For example, the word ‘binary’ is an anagram of ‘brainy’. Note that the output list should not contain duplicates. Java
IN MATLAB: Write a function file that takes a vector as an input and returns another...
IN MATLAB: Write a function file that takes a vector as an input and returns another vector with all repeated elements of the original vector. For example, the vector [3 4 1 0 4 -5 7 3] would return the vector [3 4]. Do not use the built-in function "repelem."
Write a function that takes as input an English sentence (a string) and prints the total...
Write a function that takes as input an English sentence (a string) and prints the total number of vowels and the total number of consonants in the sentence. The function returns nothing. Note that the sentence could have special characters such as dots, dashes, and so on. write a python program please.
Write a c++ trim function that takes an input of string and output the string by...
Write a c++ trim function that takes an input of string and output the string by trimming away all non-alphabetic letters.
Write a python function called unique words that takes a phrase as an input string and...
Write a python function called unique words that takes a phrase as an input string and returns a list of the unique words found in that phrase. The words should be listed in alphabetical order.
Write a recursive function named get_first_capital(word) that takes a string as a parameter and returns the...
Write a recursive function named get_first_capital(word) that takes a string as a parameter and returns the first capital letter that exists in a string using recursion. This function has to be recursive; you are not allowed to use loops to solve this problem. Test: Except: print(get_first_capital('helLo')) L s = 'great' print(get_first_capital(s)) None And Write a recursive function named count_uppercase(my_string) that finds the number of uppercase letters in the parameter string. Note: This function has to be recursive; you are not...
Write a Java method that takes a String as Input and replaces the first two occurrencesof...
Write a Java method that takes a String as Input and replaces the first two occurrencesof a given character to another provided character.   For example, if the input String is “Java is Great” and asked to replace the letter a with x then the output would be: “Jxvx is Great” The method takes a String and two characters and returns the modified String. Please make your own assumptions if needed, you do not need to write the main.
Write a function custom sort(v) that takes as input a vector v and as output returns...
Write a function custom sort(v) that takes as input a vector v and as output returns the vector w sorted into increasing order. For example, if the input is [−2 1 3 1 5], the output should be [−2 1 1 3 5]. Don’t use the built-in ”sort” function or anything similar. matlab question
C programming Write a function that takes in a 2D char array (string array) and return...
C programming Write a function that takes in a 2D char array (string array) and return a 1D char array with all the elements connected together Hint: strlen(-char*-) //returns the length of a string strcat(-char* accum-, something to add) //works like string+= in java
Write a function named "replacement" that takes a string as a parameter and returns an identical...
Write a function named "replacement" that takes a string as a parameter and returns an identical string except with every instance of the character "i" replaced with the character "n python