I need to write a function that meets the following requirements in Python.
Function name: removeTriplicateLetters()
Number of parameters: 1 string parameter where all letters are lowercase
Return value: return the modified string
Goal: Iterate over the string and remove any triplicated letters (e.g. "byeee mmmy friiiennd" becomes "bye my friennd"). You may assume any immediate following same letters are a triplicate.
SOURCE CODE:
*Please follow the comments to better understand the code.
**Please look at the Screenshot below and use this code to copy-paste.
***The code in the below screenshot is neatly indented for better understanding.
def removeTriplicateLetters(string):
output = ''
# Iterate over the input string from 0th position to (length of string-3)
i = 0
while i < len(string) - 3:
# Add that character to output
output += string[i]
# Check if triplicate
if string[i] == string[i + 1] == string[i + 2]:
i += 3
else:
i += 1
# Check for last 2 letters
if not string[-1]==string[-2]==string[-3]:
output+=string[-3:]
return output
# TEST
string = "byeee mmmy friiiennd"
output = removeTriplicateLetters(string)
print("The OUTPUT is: ", output)
-================


I need to write a function that meets the following requirements in Python. Function name: removeTriplicateLetters()...
Language: Python Function name : findwaldo Parameters : string Returns: int Description: Write a recursive function that takes in a string containing some combination of letters, numbers, and spaces, and return the starting index of the first instance of “waldo” contained in that string. If the string does not contain “waldo”, return -1. This function IS case sensitive, so “waldo” is not the same as “WALDO”. Code using string functions such as .index() and .find() that oversimplify the problem will...
Write a Python function that generates a random password which meets the following conditions: • Length = 10 • At least 2 capital letters, at least 2 small letters and at least 2 numbers. Example: ZlSyx0gDbX
In
python
Write a function called removeExtensión that is given the name of a file as a string and returns the same string without the extension (the last "" and any following characters); if the given string has no extension, return the given string without changing it. For example, removeExtension"Chapter 3.9.txt") should return "Chapter 3.9" while removeExtension("Hello") should return "Hello"
In the space below, write a C function definition for a function named StrLower, which will receive one parameter, a pointer to a null-terminated string (i.e., pointer to char), convert each character in the string to lowercase (using the tolower function from <ctype.h>), and return nothing to the caller. Inside the function definition, you may use a for loop or a while loop. If you use any variables other than the incoming parameter, you must define them locally in the...
Need in Python! Write a function definition named power that takes two formal parameters which can be assumed to be any numeric type. The first parameter is called base, the second is called exponent. The function should return the result of the base raised to the exponent power. You may not use any Python math library functions inside your function. You may create your own code to test the function in an IDE if you wish. HINT: The exponent operator in...
Python
String Product Function Name: string Multiply Parameters: sentence (str), num (int) Returns: product (int) Description: You're texting your friend when you notice that they replace many letters with numbers. Out of curiosity, you want to find the product of the numbers. Write a function that takes in a string sentence and an int num, and find the product of only the first num numbers in the sentence. If num is 0, return 0. If num > O but there...
PYTHON Programming short Questions: 1. Write a function takes as input name (string) and age (number) and prints: My name is <name> and I am <age> years old(where name and age are the inputs) 2. Write a function that takes as input a and b and returns the result of: ??ab 3. Write a function that takes as input a and b and returns the result of: ??ab if it is valid to divide a and b 4. Write a...
Hi, I have Python programming problem as follow:
Thank you.
Best Regards.
Write a function solution that, given two integers A and B, returns a string containing exactly A letters 'a' and exactly B letters 'b' with no three consecutive letters being the same in other words, neither "aaa" nor "bbb" may occur in the returned string). Examples: 1. Given A = 5 and B = 3, your function may return "aabaabab". Note that "abaabbaa" would also be a correct...
Do in Python please provide screenshots aswell.
Here are the requirements for your game: 1. The computer must select a word at random from the list of avail- able words that was provided in words.txt. The functions for loading the word list and selecting a random word have already been provided for you in ps3 hangman.py. 2. The game must be interactive; the flow of the game should go as follows: • At the start of the game, let the...
Hello, In Python, I am trying to create a function that will return the domain name from any inputted email address. For example, my input of john@domainname.com would return just the domainname. It needs to be done using regular expressions and the map function. I'm still stuck on trying to get the correct parameters for regular expression and also what is throwing it off. Thank you for your help! I am currently working with a list of different email addresses...