Post

PythonPython

I
Irshad Mohammad

Posted on 25th April 2024|12 views

0
votes

List Comprehension Python If Else

How to use if/else in list comprehension?

Answers
P
jordan chris

Posted on 25th April 2024

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