-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path8.1~8.2.py
More file actions
51 lines (35 loc) · 981 Bytes
/
8.1~8.2.py
File metadata and controls
51 lines (35 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#coding:utf-8
from __future__ import print_function, division
def backwards(string):
index = 1
while index <= len(string):
display = string[-index]
print (display,end="")
index += 1
#backwards('bundesregierung')
prefixes = 'JKLMNOPQ'
suffix = 'ack'
for letter in prefixes:
if letter == 'O' or letter == 'Q':
print (letter + 'u' + suffix)
else:
print (letter + suffix)
fruit = 'banana'
print (fruit[:])
def find(word, letter, start):
index = start
while index < len(word):
if word[index] == letter:
return index
index += 1
return -1
find("Hello", "e", 0)
def count(word, letter):
counter = 0
for i in word:
if i == letter:
counter += 1
print ('the letter', letter, 'is contained', counter, 'times in the word', word)
count('plusquamperfekt', 'p')
word = 'banana'
print (word.count('a'))