How would you return None with empty lists, I am struggling to figure out how. The code below is incomplete but it gives

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

How would you return None with empty lists, I am struggling to figure out how. The code below is incomplete but it gives

Post by answerhappygod »

How would you return None with empty lists, I am struggling to
figure out how. The code below is incomplete but it gives an idea.
Essentially I wanna call the function, a,b = a() and then since a
contains only 0's I want it to return None and return a and b
as empty lists [], to the function a,b = a(). And no
imports.
def a():

a = [0, 0, 0, 0]
b = [0, 0, 2, 0]
none(a,b)
return a,b
def none(a,b):
variables =
if all([ values == 0 for values in variables[0]
]):
print("Appears program ran into an
error state: Lists contains all zero values")
a = []
b = []
return None


a, b = a()
Thanks :)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply