-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_reader.py
More file actions
109 lines (83 loc) · 2.61 KB
/
Copy pathfile_reader.py
File metadata and controls
109 lines (83 loc) · 2.61 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from pathlib import Path
# path = Path(r'C:\Users\lyk.oda\Desktop\MF\PY.G.T\P.C.C\src\Pi_digits.txt')
# contents = path.read_text()
# # contents = contents.rstrip()
# # print(contents)
# lines = contents.splitlines()
# pi_string = ''
# for line in lines:
# pi_string += line.lstrip()
# print(pi_string)
# print(len(pi_string))
#pi_string.py
# path = Path(r'C:\Users\lyk.oda\Desktop\MF\PY.G.T\P.C.C\src\pi_millon-digits.txt')
# contents = path.read_text()
# contents = contents.rstrip()
# lines = contents.splitlines()
# pi_string = ''
# for line in lines:
# pi_string += line.lstrip()
# print(f"{pi_string[:52]}...")
# print(len(pi_string))
#pi-birthday
# path = Path(r'C:\Users\lyk.oda\Desktop\MF\PY.G.T\P.C.C\src\pi_millon-digits.txt')
# contents = path.read_text()
# lines = contents.splitlines()
# pi_string = ''
# for line in lines:
# pi_string += line.lstrip()
# birthday = input("Enter your birthday in the format mmddyy:")
# if birthday in pi_string:
# print(f"Your birthday appears in the first million pi digits")
# else:
# print(f"Your birthday doesnt exit in the first million pi digits")
#10-2 learning C
# message = "I really like dogs."
# message = message.replace('dogs', 'cats')
# print(message)
#
# def textTransforming(replacingWord):
# path = Path(r'C:\Users\lyk.oda\Desktop\MF\PY.G.T\P.C.C\src\learning_python.txt')
# converting = path.read_text()
# converting = converting.replace('Python', replacingWord)
# print(converting)
# converting.splitlines()
#textTransforming('C')
#10-3
# path = Path(r'C:\Users\lyk.oda\Desktop\MF\PY.G.T\P.C.C\src\learning_python.txt')
# content = path.read_text()
# for lines in content.splitlines():
# print(len(lines))
# write_message.py
# writing single lines
# path = Path(r'C:\Users\lyk.oda\Desktop\MF\PY.G.T\P.C.C\src\programming.txt')
# path.write_text('I love programming again.')
# writing multiple lines
# content = 'I love programming. \n' \
# 'I love creating new games. \n' \
# 'I also love working with data. \n'
# path = Path(r'./src/programming.txt')
# path.write_text(content)
# 10-4 Guest
# def guess(name):
# path = Path(r'./src/guess.txt')
# path= path.write_text(name)
# return (f'Guess:{name} succefully stored ')
# name = input('Enter your name pls:')
# call = guess(name)
# print(call)
# 10-5 Guest book
def guestBook(name):
path =Path(r'./src/guestBook.txt')
with open(path, 'a', encoding='utf-8') as file:
file.write(name + "\n")
return 'success'
limit = 5
counter = 0
while counter < limit :
name = input('Enter your name:')
respone = guestBook(name)
if respone == 'success':
counter += 1
else :
print('Error')