-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAbberivation.py
More file actions
19 lines (16 loc) · 1.07 KB
/
Abberivation.py
File metadata and controls
19 lines (16 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Some do not understand the abberviations like LOL etc. so to make it easy to read for them this program takes whole message and return
# the full message.
filename = 'abberivations.txt' # Storing the name of file in variable
usrInput = input('Enter message here\n>> ').lower() # Taking input from user
usrInput_list = usrInput.split() # Converting the user input(usrInput) to list(usrInput_list) with refrence to white space
filename = open(filename, 'r') # Opening the file
content = filename.read() # Reading the content
fileContent=content.split('\n') # Converting content into list
for word in usrInput_list:
index = usrInput_list.index(word)
if word in fileContent: # Finding usrInput_list content in fileContent
if word != 'hello': # hello is also in file so inorder to ignore this type of change this code is added
index2 = fileContent.index(word)
usrInput_list[index] = fileContent[(index2)+1] # Updating the value
output = str(' '.join(usrInput_list)) # Converting the list into string
print(output.capitalize()) # Capitalizing the string