How can I search for repeating characters in a string?
<p>I'm trying to write a function that checks for repeating characters in a string and prints false if repetition is found. Something like 'hello16' or 'secret77' would be invalid passwords.   </p>

<p>What I have so far</p>

<pre><code>def password_check():
    if pw.isalpha() == True:
        print('Password must contain at least one number.')
    elif pw.isdigit() == True:
        print('Password must contain at least one letter. ')
    else:
        print('True')
pw = input('Enter new password: ') 

 #--------------------------------------------------- revised code below

def password_check(pw):
if len(pw) &lt; 2:
    print ('Password must be at least 2 characters long')
elif pw.isalpha():
    print('Password must contain at least one number.')
    return False
elif pw.isdigit():
    print('Password must contain at least one letter. ')
    return False
for a in pw:
    if a * 2 in pw:
        print('Password contains a consecutive character')
        return False
print('Password was accepted')
return True

pw = input('Enter new password: ')
password_check(pw) # Call your function
</code></pre>