def new_pass():
User_new = input('Enter Username: ')
Pass_new = input('Enter Password: ')
output_final = User_new + ' ' + Pass_new
with open('new.txt', 'w') as new_folder:
new_folder.write(output_final)
return 'Done'
new_pass()
allthelines = open("new.txt")
allthelines = allthelines.split()
This is how I am trying to use one function; but when I'm rerunning it it is not letting me access the data.
I want the text file to be like this:
string 1
string 2
string 3, string 4
string 5, string 6
This is the output I am getting:
Enter Username: Example
Enter Password: Example2
Traceback (most recent call last):
File "/Users/kavneet/Desktop/Project/maincode.py", line 10, in <module>
allthelines = allthelines.split()
AttributeError: '_io.TextIOWrapper' object has no attribute 'split'
(base) Kavneets-MacBook-Air:~ kavneet$
I want it to be a dict of lines like the 3rd and 4th. How can I do this? Also how do I insert text one the next line. Any help is appreciated!