logo-MindMajix
PostPythonPython
I
Irshad Mohammad

Posted on 21st July 2024|12 views

0
votes

List Comprehension Python If Else

How to use if/else in list comprehension?

1 answers
Answers
P
jordan chris

Posted on 21st July 2024| views

Here is one way that is easy 

Example:

def change(z): 

if z is None: return unicode(z.strip()) 

else: return '' 

row = [change(b) for b in row]

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number