4

I have this code:

sys.stdout.write("\r [*] Serching for "+FirstName+" AND "+LastName )
sys.stdout.flush()

But when I put it in loop, step by step I have mixture of FirstNames with each other and also LastNames with each other.

Searching for TEST_THREE AND EXAMPLE_THREE   #First time
Searching for TEST_TWOEE AND EXAMPLE_TWOEE   #Next time 

You see there is EE of THREE after TWO...

How can I fix it?

1 Answer 1

5

Pad the string with extra spaces. For example, using str.ljust:

msg = "[*] Serching for {} AND {}".format(first_name, last_name)
sys.stdout.write("\r " + msg.ljust(70))
sys.stdout.flush()

using str.format:

msg = "[*] Serching for {} AND {}".format(first_name, last_name)
sys.stdout.write("\r {:<70}".format(msg))
sys.stdout.flush()
Sign up to request clarification or add additional context in comments.

1 Comment

Pardon but I have the ERRO: AttributeError: 'str' object has no attribute 'foramt'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.