s = "Hello, Raj"
for c in s:
print(c)
H e l l o , R a j
nvowels = 0
for c in s:
if c == 'a' or c == 'e' or c == 'i' or \
c == 'o' or c == 'u':
nvowels = nvowels + 1
print(nvowels)
3
nvowels = 0
for c in s:
if c in 'aeiouAEIOU':
nvowels = nvowels + 1
print(nvowels)
3
sum([1,2,3,4,5])
15
def mysum(xs):
sum = 0
for x in xs:
sum = sum + x
return sum
mysum([10,40,90])
140
mysum([-1,2,3,5])
9
mysum(["a","b"])
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Input In [12], in <cell line: 1>() ----> 1 mysum(["a","b"]) Input In [9], in mysum(xs) 2 sum = 0 3 for x in xs: ----> 4 sum = sum + x 5 return sum TypeError: unsupported operand type(s) for +: 'int' and 'str'
s = "hello"
answer = ""
for c in s:
d = c.upper()
answer = answer + d
print(answer)
HELLO
def encrypt(s):
shift = int(s[0:2])
message = s[6:]