Methoden der Datentypen string und list
#Methoden des Datentyps String
n='abcdefgh'
print n #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n.upper() #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n.lower() #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n.title() #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[0] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[4] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[-1] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[-2] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[:4] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[0]+n[2] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[4:] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[-2:] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[:4]+n[4]+n[5:] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print n[:2]+n[4]+n[5:] #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print len(n) #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print min(n) #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print max(n) #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print "x".join(n[0]+n[1]) #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print "x".join(n[:4]) #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
#Methoden des Datentyps Liste
vornamen = ['Ajax', 'Elke', 'Matty'] ;
print(vornamen[0]; #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print(vornamen[1]); #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print(vornamen[3]); #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
vornamen.append("Silke") ;
print vornamen; #[
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
]
del vornamen[1] ;
print vornamen; #[
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
]
print vornamen.pop(0); #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print vornamen.pop(); #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
print vornamen.join(" x "); #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
vornamen.insert(1,"Friederike");
print vornamen; #[
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
]
vornamen.remove('Ajax');
print vornamen; #[
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
]
print vornamen.count('Matty'); #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
vornamen.clear();
print vornamen; #
1
8
a
abcd
abcdefgh
ABCDEFGH
Abcdefgh
abefgh
ac
Ajax
Ajax x Matty x Silke
'Ajax', 'Elke', 'Matty', 'Silke'
'Ajax', 'Friederike', 'Matty'
'Ajax', 'Matty', 'Silke'
axb
axbxcxd
e
efgh
Elke
Falscher Zugriff
'Friederike', 'Matty'
gh
h
Leere Liste
letzter Buchstabe
Silke
vorletzter Buchstabe
Check
OK