Skip to content

Commit 60751a4

Browse files
committed
10 May 2021
1 parent 4365801 commit 60751a4

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

Lists & Strings/3.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fhand = open('Mytext.txt')
2+
for line in fhand:
3+
line = line.rstrip()
4+
if not line.startswith('From '):
5+
continue
6+
words = line.split()
7+
print(words[2])
8+
9+
10+
line = 'From [email protected] Sat Jan 5 09:14:16 2021'
11+
words = line.split()
12+
print(words)

Lists & Strings/4.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# # The Double Split Pattern
2+
# Sometimes we split a line one way, and then grab one of the pieces of the line and split that piece again.
3+
line = 'From [email protected] Sat Jan 5 09:14:16 2021'
4+
words= line.split()
5+
email = words[1]
6+
print(email)
7+
pieces = email.split('@')
8+
print(pieces)

Lists & Strings/List Summary.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Concept of a collection
2+
3+
# Lists and definite loops
4+
5+
# Indexing and lookup
6+
7+
# List mutability
8+
9+
# Functions: len, min, max, sum
10+
11+
# Slicing Lists
12+
13+
# List methods: append, remove
14+
15+
# Sorting lists
16+
17+
# Splitting strings into lists of words
18+
19+
# Using split to parse strings

Lists & Strings/Mytext.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
From [email protected] Sat Jan 5 09:14:16 2021

0 commit comments

Comments
 (0)