Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. def split_in_two(list,number): #declares a split_in_two function
  2.     a = list[2:] #assingns a variable a to that prints the list from index 2 till the end of the list
  3.     b = list[0:2] #assigns a  variable b that prints the list from index 0 to 1
  4.     if number % 2 == 0: #checks if the number is an even number
  5.         print(a) #prints a if the number is even
  6.     else:
  7.         print(b) #if it is odd it prints b
  8. list = ["a","b","c","d","e","f"] #assings the list to the variable list
  9. split_in_two(list,4) #calls the fuction split_in_two
  10.  
  11. split_in_two(list,3) #calls the function split_in_two
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement