Oct-15-2017, 04:06 AM
I am a python newbie and I am trying to make a function that returns True if a given str is nonrepetitive and False otherwise.
For example,
>>> nonrepetitive("abcab")
True
>>> nonrepetitive("12341341")
False
Hints I was given was that I could ask if two strings are equal to each other and to use slicing
The following is what I have so far:
For example,
>>> nonrepetitive("abcab")
True
>>> nonrepetitive("12341341")
False
Hints I was given was that I could ask if two strings are equal to each other and to use slicing
The following is what I have so far:
def repetitive(s): for i in s: if i == [i]+1: return True else: falsePlease if anyone can help me out that would be appreciated