You are on page 1of 2

def toLowerCase (s):

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

print substringOccurrences("hello", "o")

You might also like