top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

An introduction to List Comprehension

python is eminent for encouraging developers and Data Scientist write efficient, easy to understand code and a simple to read code as well


List comprehensions are used for creating new lists from other iterables like tuples, strings, arrays, lists, etc. A list comprehension consists of brackets containing the expression, which is executed for each element along with the for loop to iterate over each element.


syntax:

newList =[ expression(element) for element in oldList if condition ]


Advantages of List Comprehension


  1. Require fewer lines of code

  2. Transforms iterative statement into a formula

  3. More time efficient and space efficient than loops

Iterating through a String using List comprehensions


h_letters = [letter for letter in "letter"]
print(h_letters)

When we run the program, the output will be:


['l','e','t','t','e','r']

in the above example, a new list is assigned to variable h_letters, and list contains the items of the iterable string 'letters'

we type the print() function to call the output


 
 
 

コメント


COURSES, PROGRAMS & CERTIFICATIONS

 

Advanced Business Analytics Specialization

Applied Data Science with Python (University of Michigan)

Data Analyst Professional Certificate (IBM)

Data Science Professional Certificate (IBM)

Data Science Specialization (John Hopkins University)

Data Science with Python Certification Training 

Data Scientist Career Path

Data Scientist Nano Degree Program

Data Scientist Program

Deep Learning Specialization

Machine Learning Course (Andrew Ng @ Stanford)

Machine Learning, Data Science and Deep Learning

Machine Learning Specialization (University of Washington)

Master Python for Data Science

Mathematics for Machine Learning (Imperial College London)

Programming with Python

Python for Everybody Specialization (University of Michigan)

Python Machine Learning Certification Training

Reinforcement Learning Specialization (University of Alberta)

Join our mailing list

Data Insight participates in affiliate programs and may sometimes get a commission through purchases made through our links without any additional cost to our visitors.

bottom of page