+ 1

Isogram detector (Python with regex)

I have tried to solve this problem with reg. expressions but when there is any repetition give false when it should come true. Can anyone help me? import re x=input() y=r"([a-z])?" if re.search(x,y): print ("true") else: print ("false")

16th Oct 2021, 11:34 AM
Norberto Costa
Norberto Costa - avatar
4 ответов
+ 2
Can you please give example inputs since it is not clear what exactly the problem is?
16th Oct 2021, 1:04 PM
Devnull
Devnull - avatar
0
Ok. Objective: detect words without any of the letters repeated. Example: come(0 letters repetead), sololearn(o and l are repeted).
16th Oct 2021, 1:07 PM
Norberto Costa
Norberto Costa - avatar
0
Try this: word=input() list_word=list(word) n=0 while n < len(list_word): if list_word.count(list_word[n]) == 1: n+=1 else: break if n==len(list_word): print ("true") else: print ("false")
26th Nov 2021, 11:42 PM
Juan
Juan - avatar
0
import re s=input().lower() pattern=r'([a-z]).*\1' if re.search(pattern,s): print('false') else: print('true')
12th May 2022, 12:30 AM
MING ZI CHEN
MING ZI CHEN - avatar