How to build a programme that creates files automatically in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to build a programme that creates files automatically in python?

Hi. I have a project for my programming class and we have to create a programme for diabetic users. In order to do this,my teacher explained that we needed to create a way for the programme to recognize if a user exists or not and if doesn't exist then we need to create a new file that will save the users information to use later. Please!!! I really need help!!!!

29th Dec 2019, 12:39 AM
Olívia
Olívia - avatar
1 Answer
0
I have programm only for 1 user but i hope you can make this better try: f=open("test.txt") #open file test.txt login=f.readline(1) #read 1 line password=f.readline(2) # read 2 line except FileNotFoundError: f=open("test.txt","w") #open file in write mode login=input("Enter you login: ")+"\n" password=input("Enter you password: ") f.write(login) f.write(password) print("You login is "+login+" You password is"+password) #print login and password
29th Dec 2019, 1:29 AM
Oleg Racov
Oleg Racov - avatar