Note that there are some explanatory texts on larger screens.

plurals
  1. POis it possible to add colors to python output?
    text
    copied!<p>so i made a small password strength tester for me, my friends and my family, as seen here:</p> <pre><code>import re strength = ['You didnt type anything','Terrible','weak sause','avarage','Good!','Very Strong', 'THE FORCE IS STRONG WITH THIS ONE'] score = 1 password=(raw_input("please type in the password you would like rated:")) if len(password) &lt; 1: print strength[0] if len(password) &gt;=1 and len(password)&lt;=4: print strength[1] else: print "" if len(password) &gt;=7: score+=1 print "password was made stronger by not being short" else: print "Your password is really short, concider making it longer" if len (password) &gt;=10: score+=1 print "password was made stronger by long" else: print "An even longer password would make it stronger" if re.search('[a-z]',password) and re.search('[A-Z]', password): score+=1 print "password was made stronger by having upper &amp; lower case letters" else: print "Indlucing both upper and lower case letters will make your password stronger" if re.search('[0-9]+', password): score+=1 print "Password was made stronger by using numbers" else: print "Using numbers will make your password stronger" if re.search('[.,!,@,#,$,%,^,&amp;,*,?,_,~,-,£,(,)]',password): score+=1 print "Password was made stronger by using punctuation marks and characters" else: print "Using punctuation marks and characters will make the password stronger" print "\n final password rating is:" print strength[score] </code></pre> <p>what i was hoping to do is:</p> <p>1st - add color to the comments i've given the user about the content of their password, good comments such as the: <code>"password was made stronger by using numbers"</code> will have a green output, while constructive feedback such as the <code>"using numbers will make your password stronger"</code> will have a red output, making it easier for the user to spot the pros and cons of his password</p> <p>2nd - i was wondering, if it works the same, can i color certain items in my above "strength" list? making the first two red, the middle pair yellow and the last pair green?</p> <p>ty!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload