Python Forum
if and for statements on the same line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if and for statements on the same line
#1
Hello friends,
I have a very easy question but since I am a beginner I could not solve it.
I have a list like
a=[1 2 3 -4]
what I wanted to do
if (condition x>condition y and all the elements of list a is greater than 0)
do this
else:
do that
how can I check the each element of list a if they are greater than 0 on the "if" line?
Thank you so much
I tried to to do something like if (condition x>condition y and [n for n in a >0]:
but it did not work
I will be very happy, if you can help me


Messages In This Thread
if and for statements on the same line - by juniorcoder - Sep-10-2018, 02:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  If-Print statements on the same line ClassicalSoul 1 2,293 Jan-31-2019, 02:14 PM
Last Post: buran
  Do I always have to use triple quotes or \n for multi-line statements? DragonG 3 2,650 Oct-24-2018, 11:21 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020