Skip to content

Commit 46efbc5

Browse files
authored
Add files via upload
1 parent 286d43d commit 46efbc5

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
with open("wipe_file.txt", "w") as f:
2+
f.write("")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
hello this file is
2+
going to be deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#------Search for the word irrespective of how its written-----#
2+
3+
word = input("Enter the word you want to search for in \'Qfile.txt\': ")
4+
5+
with open("Qfile.txt") as f:
6+
content = f.read()
7+
8+
if word.lower() in content.lower():
9+
print(f"The word \'{word}\' is in the \'Qfile.txt\'")
10+
else:
11+
print(f"The word \'{word}\' is not in the \'Qfile.txt\'")
12+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#--------Give the 'line no' for first occurance of given word.
2+
word = input("Ente the word to get it\'s line no: ")
3+
4+
with open("Qfile.txt") as f:
5+
lines = f.readlines()
6+
7+
line_no = 1
8+
9+
for line in lines:
10+
if word.lower() in line.lower():
11+
print(f"The word \'{word}\' is present in line no: {line_no}")
12+
break
13+
line_no += 1
14+
15+
else:
16+
print(f"The word \'{word}\' is not in the \'Qfile.txt\'")
17+

0 commit comments

Comments
 (0)