0
Hello!
I’m trying to develop a program that reads a string and returns a boolean if there are repeated characters.
I need enough on that score:
("") // False
("oo") // False
("po") // True
("EEEttOo") // False
("PoiX2@op") // False
("PoiX2@aP") // False
("PoiX2@p@") // False
("PoiX2@2pa") // False
("PoiX2@pa") // True
I thought it would be easier to work with string, passing it to a list and doing a check with for and if however, I’m not able to develop a valid logic.
s = 'Banana'
listastr = list(s)
out = True
Could someone give me a light on how to solve?
I am basing that "p" is different from "P" and the fact that " has given False, is due to the system requiring an entry.
In my system, I’m using Regex, so it searches for the characters [a-z],[A-Z],[0-9] and some special characters.
Implies that if a string has no duplicates it returns
True
and if you have duplicates returnsFalse
. In""
the empty string does not contain duplicates and returnsFalse
and in"PoiX2@pa"
the string has a repeat ofp
, one uppercase and one lowercase, and returnTrue
. These results are correct?– Augusto Vasques
Yes, I am basing that "p" is different from "P" and the fact that " has given False, is due to the system requiring an input. In my system, I’m using Regex, so it searches for the characters [a-z],[A-Z],[0-9] and some special characters. Since I haven’t found any regular expression that doesn’t accept character repetition that works, I’m looking for an alternative by for and if.
– Alan Bertoldo