List Comprehension

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

List Comprehension Syntax

(Manipulate) for (item) in (list): nums = [1,2,3] nums2 = x*10 for x in nums nums2 = [10, 20, 30]

LC with conditional Logic

evens = [num for num in numbers if num % 2 == 0]

Nested Lists

lists can contain any kind of element, even other lists

Nested list comprehension

nested_list = [[1,2,3],[4,5,6],[7,8,9]] [[print(val) for val in 1] for 1 in nested_list]

Accessing Nested Lists

nested_list = [[1,2,3],[4,5,6],[7,8,9]] for 1 in nested list: for val in 1: print(val)


Kaugnay na mga set ng pag-aaral

Absolute Java: Swing I / The Art and Science of Java: Event-driven Programs

View Set

pedi fall 18 final exam McKinney

View Set

Pharmacological and Parenteral Therapies Type: Client Needs Category: Pharmacological and Parenteral Therapies

View Set

How Things Work 10.1 Static Electricity

View Set

Chapter 8. Master Budgeting Learn Smart

View Set

Ch.5 Ethical Applications of Informatics

View Set

Ciencias Naturales - Tema 5.3.- Las reacciones químicas

View Set

MedSurg Exam 2 Practice Questions

View Set

Chapter 8, Week 8 APT Ch.8,9 TED ch.10,11, Practice quiz 3 questions: POLSC 115, PLS 105 EXAM 3 CHAPTERS 8,9,10

View Set