Generation

generate functionSat, 03 Dec 2022

Robert is given a string that ends with a character or a number He has to check the length of the given string and append it to the end in such a way that if the original string ends with a number then the new string with the appended value must have the length of the string as the last two characters. If the string ends with a character then append the total length as the last character Also, the number to be appended must be a single positive digit Write a code to implement the given scenario.

def AppendValue(s): # write your code here return s

Questions about programming?Chat with your personal AI assistant