Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #switch from ben to charlie
- def ben_to_charlie(ben_sequence):
- charlie_sequence = []
- print(ben_sequence)
- loops = len(ben_sequence)
- charlie_sequence.append(ben_sequence[0])
- for i in range (1, loops):
- thing1 = (charlie_sequence[i-1])
- thing2 = (ben_sequence[i])
- charlie_sequence.append(thing1 + thing2)
- print("charlie's sequence is\n", charlie_sequence)
- #switch from charlie to ben
- def charlie_to_ben(charlie_sequence):
- ben_sequence =[]
- print(charlie_sequence)
- loops = len(charlie_sequence)
- ben_sequence.append(charlie_sequence[0])
- for i in range (1, loops):
- thing1 = charlie_sequence[i]
- thing2 = charlie_sequence[i-1]
- ben_sequence.append(thing1 - thing2)
- print("ben's sequence is", ben_sequence)
- #input and store their sequence as an array
- sequence_length = int(input("how long is your sequence? "))
- their_sequence = []
- for i in range (sequence_length):
- their_input = int(input("input sequence "))
- their_sequence.append(their_input)
- #choose which function to run on sed array
- switch = int(input(" Do want to change this sequence from \n (1) ben --> charlie / ana --> ben \n or \n (2), charlie-->ben / ben-->ana \n"))
- if switch == 1:
- ben_to_charlie(their_sequence)
- elif switch == 2:
- charlie_to_ben(their_sequence)
- else:
- print("invalid response")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement