Last active
March 9, 2022 15:49
-
-
Save alipbudiman/53d41f056c9d8a6299daa4f72ecac5f9 to your computer and use it in GitHub Desktop.
cek bilangan konsekutif di python3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#konsekutif | |
p = str(input("masukan bilangan: ")) | |
ls = [] | |
stat = 'konsekutif' | |
stat2 = True | |
xi = p.isnumeric() | |
if xi == True: | |
for x in p: | |
ls.append(int(x)) | |
inext = None | |
for i in ls: | |
if inext == None: | |
inext = i | |
else: | |
if i - inext != 1 and i - inext != -1: | |
stat = 'non-konsekutif' | |
stat2 = False | |
break | |
else: | |
inext = None | |
print(stat) | |
print(stat2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment