Question

in python please The following statement creates a list, please rewrite it using a different way...

in python please

The following statement creates a list, please rewrite it using a different way but creating the same list.            Lst = [j for j in range (100) if j % 2 == 0]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student,

Yes, you can write the given statement in other way as given in the following.I have also written the comments for your better understanding.

==============================================================

Program:

==============================================================

#create an empty list

Lst = []

#loo for j = 0 to 100

for j in range(100):

    #if j is divided by 2 then add the j to list

    if j % 2 == 0:

        Lst.append(j)

#print the list

print(Lst)


=============================================================

Sample Output:

Urma sharma@ubuntu:~$ python3 list.py [O, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44,

=============================================================

Kindly Check and Verify Thanks..!!!

Add a comment
Know the answer?
Add Answer to:
in python please The following statement creates a list, please rewrite it using a different way...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT