#!/usr/bin/python3 # Tuples - Immutable - between () my_str = "XUXUBELEZA" my_tuple = (2, "one", "three", 3.5) tuple2 = (9, 10) tuple3 = ("one",) # notice the extra comma print(my_tuple + tuple2) # Lists - looks like a lot like a tuple... between [] # Usually homogeneous (but we can have different types) # - Big difference is that lists are mutable a_list = [] b_list = [2, 'a', 3, 'b', True] L = [2, 1, 3] L2 = ['a', 'b', 'c'] L3 = L + L2 ######################################### i = 0 new_tup = () while i < len(my_tuple): print(my_tuple[i]) new_tup += (my_tuple[i],) i+=1 print(my_tuple[0:-1]) print("#####################3") #print(L) L.append(10) #print(L) #L.extend(L2) print(L3) #print(L) del(L3[3]) # Delete a specific inded print(L3) L3.pop() # Delete the last item of the list print(L3) L3.remove('b') # Delete the 1st appearance of that item print(L3) my_list = list(my_str) print(my_list) print(my_str.split('B')) # Split a string on a specific character print("_".join(my_list)) # Join string elements in a list to a string print(sorted(L)) # Sort but not mutate the string L.sort() # Sort the list in place print(L)