I'm new to coding so this is probably a really easy question for you all. But I'm trying to take the first and last character of a word and see if it's sequential in that word (not alphabetically). For example, 'banana' would be sequential because 'ba' appears in the word. However, 'house' would not be sequential because 'he' does not appear in the word. If a word is sequential, it returns "True", if not "False". I'm writing this in python. Thanks!
Asked
Active
Viewed 24 times
1 Answers
0
def seq(s):
if (s[0]+s[-1]) in s:
return True
return False
print(seq(s))

zeeshan12396
- 382
- 1
- 8
-
2You could `return` the boolean directly, rather than using it in an `if` statement. – CrazyChucky Feb 10 '22 at 05:25
-
2