Skip to content

Commit bb50b62

Browse files
Add files via upload
0 parents  commit bb50b62

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
file_name=input('Enter file name:') #ask user for file name
2+
3+
file_path=open(file_name)#open the file name input given by the user
4+
list=list()#create a empty list
5+
6+
for lines in file_path:#iterate over the lines in the file
7+
words=lines.split()#split the line using spaces and store them in list
8+
for i in words:#iterate the list created for each element
9+
if i in list:continue#continue to loop if current element is in the list
10+
list.append(i)#else add the unique element to the list
11+
12+
list.sort()#sort the list alphabetically
13+
print(list)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
But soft what light through yonder window breaks
2+
It is the east and Juliet is the sun
3+
Arise fair sun and kill the envious moon
4+
Who is already sick and pale with grief

0 commit comments

Comments
 (0)