I'm trying to write some functions.
This first function is suppose to help shuffle two strings which are the same length into the correct word.
So the output would be something like:
After shuffling the first string som and the second string trs the word is storms.
Here is my code now:
I don't know if I'm starting this correctly, hopefully I am though. Problem with this is that I don't know how to rearrange the a and b to reorder it in order from  onwards.
def reorder(a, b): """ returns a "shuffled" version of a + b: something like a + b + a + b + a + b + so on... """ reorder_str = a + b for i in range(len(reorder_str)): reorder_str = a[i] + b[i] return reorder_str #Testing function: first_str = "som" second_str = "trs" final = reorder(a, b) print "After shuffling the first string " +str(first_str) + " and the second string" + " " + str(second_str) + " the word is" + " " + str(reorder) + "."
The second function I'm trying to create is to find even numbers within a list and return a new list that only gives the elements divisible by 2.
The original list itself should not be changed though.
So for example:
lista = [1,2,5,6,7]
evenlist = even_list(lista)
My code right now is:
(The problem I have here is that I don't know how to output the new list with only even numbers)
def even_list(a): """ original list will remain unchanged and the new list will only return the integers that are even """ lista =  for i in range(len(lista)): if i % 2 == 0: lista = lista % 2 return lista #Testing the function lista = [1,2,5,6,7] evenlist = even_list(lista) print lista print evenlist
Thanks for any help/hints/explanation/suggestions.
Edited by saikeraku: n/a