This document contains definitions for several string manipulation functions:
1) The toLowerCase function takes a string and returns it in lowercase by checking if each character is uppercase and converting it.
2) The toLowerCase2 function takes a string and returns it in lowercase by iterating through each character, checking if it is lowercase or uppercase, and converting uppercase characters.
3) The deleteDigits function takes a string and returns a new string with all digit characters removed by iterating through each character and only including non-digit characters.
4) The find function takes a string and character, iterates through the string, and returns the index of the first occurrence of the character.
5) The substringOcc
This document contains definitions for several string manipulation functions:
1) The toLowerCase function takes a string and returns it in lowercase by checking if each character is uppercase and converting it.
2) The toLowerCase2 function takes a string and returns it in lowercase by iterating through each character, checking if it is lowercase or uppercase, and converting uppercase characters.
3) The deleteDigits function takes a string and returns a new string with all digit characters removed by iterating through each character and only including non-digit characters.
4) The find function takes a string and character, iterates through the string, and returns the index of the first occurrence of the character.
5) The substringOcc
This document contains definitions for several string manipulation functions:
1) The toLowerCase function takes a string and returns it in lowercase by checking if each character is uppercase and converting it.
2) The toLowerCase2 function takes a string and returns it in lowercase by iterating through each character, checking if it is lowercase or uppercase, and converting uppercase characters.
3) The deleteDigits function takes a string and returns a new string with all digit characters removed by iterating through each character and only including non-digit characters.
4) The find function takes a string and character, iterates through the string, and returns the index of the first occurrence of the character.
5) The substringOcc
if len(s) > 1: return s if s >= "a" or s <= "z": return s if s >= "A" or s <= "Z": return chr(ord(s) + 32)
print toLowerCase("A")
def toLowerCase2 (s):
result = "" if len(s) < 1: return s for x in s: if x in "abcdefghijklmnopqrstuvwxyz": result = result + x if x in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": result = result + chr(ord(x) + 32) return result
s[1:5]
def deleteDigits (s):
result = "" for x in s: if x not in "1234567890": result = result + x return result
print deleteDigits("a1b2c3")
def find (s,c):
re = -1 t = 0 result = "" if len(s) < 1: return re for x in s: if x == c: return t t = t + 1
print find('hello', 'o')
def substringOccurrences (s,t):
re = -1 c = 0 result = "" if len(s) < 1: return "0" for x in s: if x <= t: c = len(t) return c