August 2016
Beginner to intermediate
352 pages
9h 20m
English
#!/usr/bin/env python3farm_animals=['cow','pig','horse']domestic_animals=['dog','cat','gold fish']zoo_animals=['lion','elephant','gorilla']animals=farm_animals+domestic_animals+zoo_animalsforindex_valueinrange(len(animals)):("{0:d}: {1!s}".format(index_value,animals[index_value]))
#!/usr/bin/env python3animals_dictionary={}animals_list=['cow','pig','horse']other_list=[4567,[4,'turn',7,'left'],'Animals are great.']forindex_valueinrange(len(animals_list)):ifanimals_list[index_value]notinanimals_dictionary:animals_dictionary[animals_list[index_value]]=other_list[index_value]forkey,valueinanimals_dictionary.items():("{0!s}: {1}".format(key,value))
#!/usr/bin/env python3list_of_lists=[['cow','pig','horse'],['dog','cat','gold fish'],\['lion','elephant','gorilla']]foranimal_listinlist_of_lists:max_index=len(animal_list)output=''forindexinrange(len(animal_list)):ifindex<(max_index-1):output+=str(animal_list[index])+','else:output+=str(animal_list[index])+'\n'(output)
Read now
Unlock full access