How to not print None
st = 0.03 def sp(str): for letter in str: sys.stdout.write(letter) sys.stdout.flush() time.sleep(st) print()
So if i do sp(input("Enter Password"))
I get None in the console,
how to fix it???
just do print(letter,end="",flush=True)
sys is not needed here, Idk if that will fix it, but I do know that optimization is possible
this is if your working in python 3, in 2 I cant help you.
Its working. Thanks @SeamusDonahue
To be fair, I will have to mark the first answer as correct. I am sorry if that offends you. :) @SeamusDonahue
no, it's fine. It didn't answer the question here, but something else did, that's just how it works :) @abdullahrajput9
for one thing. You need to name whether it is a str
or a int.
either of them specifying will remove the none
.
Yup, its working now. Thanks @RYANTADIPARTHI
To be fair, I will have to mark the first answer as correct. I am sorry if that offends you. :) @RYANTADIPARTHI
Hello. This is because input is not clearly defined as a string here!
So, after you define sp(str) and print(), you should NOT directly code
sp(input("Enter Password")
You should first code:
a = str(input("Enter Password"))
sp(a)
This should work out fine. Hope it helps!
input already returns a string with whatever the user typed. @dhruvkumarrajan
@SeamusDonahue
yeah, thanks for pointing it out! :)
Thanks, it worked out right :) @dhruvkumarrajan
@abdullahrajput9
np :)