Click here to Skip to main content
15,886,049 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my code so far;


Username = input ("Please enter your Username: ")
Password = input ("Please enter your Password: ")
print ("")
print ("Your selected username: ", Username)
print ("Your selected password: ", Password[0:5]+)
(This is in bold as I just had to show that I am already telling python to start by only displaying the first 5 letters of the password)


So, what I want to do is replace the letters after the 5th letter of the password that the user enters with #'s. So for example if the password the user enters is "Password", it will print "Passw" followed by "###" (replacing "ord"). It's like what they do in email verifications sometimes when it displays your full Username but only 5-6 letters of your password. Thanks in advance for any replies.
Posted

1 solution

Try this:
str = "Password";
str = str[:5] + "#" * len(str[5:])
print str;
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900