Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_alternating(arr):
- if len(arr)<3:
- return True
- even=arr[0]
- for i in range(2,len(arr),2):
- if arr[i]!=even:
- return False
- odd=arr[1]
- for i in range(1,len(arr),2):
- if arr[i]!=odd:
- return False
- return True
- def main():
- print("alternating.py\nDeveloped by Pedro Izecksohn.")
- s=input("Enter the values separated by comma: ")
- arr=s.split(",")
- print(is_alternating(arr))
- if __name__=="__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment