Search code examples
pythonpasswords

Removing space between printed generated passwords


I wrote a Python script to crack the password of forgotten accounts. However, everytime I print a password, there is a space between "Hacked/hacked" and whatever else.

I suspect that the space character is somewhere in the password variables. No matter what I do, my IDE won't let me remove that space between the quotes in the password variable. How can I remove it?

Here's the code:

while True:
   import random
   num ="12"
   ans = num + "-"
   ans2 = num + "/"
   ans3 = num + "_"
   length = 3
   password ="".join(random.sample(ans,length))
   password2 ="".join(random.sample(ans2,length))
   password3 ="".join(random.sample(ans3,length))
   print("Hacked",password)
   print("hacked",password)
   print("Hacked",password2)
   print("hacked",password2)
   print("Hacked",password3) 

Solution

  • Several ways to solve this:

    print(f'HACKED{var}')
    print('HACKED'+var)