0

Please tell please!!if i write like this!! This code is also not working properly!! only Q is getting written on file earn.txt

#if i write like this!! This code is also not working properly!! #only Q is getting written on file earn.txt !! Why any other thing isn't getting attached to that file(earn.txt) with open('earn.txt', 'w') as file: a = True while a: b = input("Enter Your Name\n(Type Q to Quit)\n") if b == 'Q': break file.write(b)

19th May 2020, 8:13 AM
Lucky Nayak
Lucky Nayak - avatar
3 Antworten
+ 2
Look at what b is equal to when you break from the while loop. The only place you write to the file is after the loop. Also, keep in mind that mode 'w' will overwrite the file when used.
19th May 2020, 8:54 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thank You Guys
19th May 2020, 9:03 AM
Lucky Nayak
Lucky Nayak - avatar