Ask coding questions

← Back to all posts
how do we transport an user given input to a file using file IO
ROCKINGRAYQUAZA

how do we transport an user given input to a file using file IO.I am taking user input and then appending it to the file named "names"but when i am typing the input it is not showing anything in the file so please help..your help will be appreciated..

Voters
ROCKINGRAYQUAZA
Comments
hotnewtop
[deleted]

you can do something like this.

Hope this helps!

ROCKINGRAYQUAZA

bro why did u use f before hello??I am new to python so please [email protected]

[deleted]

@ROCKINGRAYQUAZA F-strings. They basically can include information INSIDE of a string instead of closing off the string, putting the variable name, then going back to a string. You can see some docs here.

ROCKINGRAYQUAZA

what if i write f=open("names","a")
f.write(n) .......then why is it not working??what is the differencee
@eekboi

ROCKINGRAYQUAZA

eekboi after this i will select your answer
@ROCKINGRAYQUAZA

[deleted]

@ROCKINGRAYQUAZA First off, the syntax of that is wrong. Second, it's inneficient.

ROCKINGRAYQUAZA

thank you eekboi

[deleted]

@ROCKINGRAYQUAZA My pleasure.

ROCKINGRAYQUAZA

please help me..i need the input to be saved in the "names' file

dillonjoshua68

Is it possible for you to share the repl here? To do so.... you have to click the edit button on this post, and then select the repl, then we can see the problems and help @ROCKINGRAYQUAZA

ROCKINGRAYQUAZA

thanks bro but i have got my [email protected]

ROCKINGRAYQUAZA

please help me..

gibbsfreenergy

let me try c-ing whats wrong. @ROCKINGRAYQUAZA