File handling . This code is returning blank lines. Tryingto make a program to make you sleep. Is incomplete btw | Sololearn: Learn to code for FREE!

0

File handling . This code is returning blank lines. Tryingto make a program to make you sleep. Is incomplete btw

x = input() f = open("dhruv.txt", "w+") def wrt(x, n): if x == "": s = str(n) + " Sheep \n" f.write(s) n += 1 print(f.readline()) y = input() wrt(y, n) else: print("Sweet Dreams!!!") wrt(x, 0)

11/3/2019 5:22:23 PM

Dhruv Dutta

5 Answers

New Answer

+6

Could you explain what you're actually trying to do in a simple word

0

I am making a program which when is run. Accepts input. Each time the enter key is pressed i want to print the counting of sheeps.and when anything else than the enter key is pressed then the program assumes that the person is asleep. Basically it would be a program to make someone feel sleepy.

0

I actually am a newbie so dont know much about file handling

0

But why do you want to use files in this program .you can do without files.🤔🤔

0

I want to use files please.i know it is easier without it.