I have a text file with given below content
Credit
Debit
21/12/2017
09:10:00
Written python code to convert text into set and discard \n.
with open('text_file_name', 'r') as file1:
same = set(file1)
print (same)
print (same.discard('\n'))
for first print statement print (same). I get correct result:
{'Credit\n','Debit\n','21/12/2017\n','09:10:00\n'}
But for second print statement print (same.discard('\n'))
. I am getting result as
None
.
Can anybody help me to figure out why I am getting None. I am using same.discard('\n')
to discard \n
in the set.
Note: I am trying to understand the discard function with respect to set.