hi i want to check if a string from user input has two repeated characters/letters in a string next to eachother.. i have a simple code to check if the first letter and second letter in the string are the same.
def two_same():
d = []
while len(d) <= 1:
d = input("enter the same letter twice:")
if d[0] == d[1]:
return print(d[0])
two_same()
As the comments already mentioned you should use a for loop:
def two_same(string)
for i in range(len(string)-1):
if string[i] == string[i+1]:
return True
return False
result = ""
while not two_same(result):
result = input("enter the same letter twice:")
print(result)