0

I want to run a code like this:

 a = [s,sd,f,r]
 if len(a)>0:
     print("Length is greater then '0'")
 else:

What should I put under else: if do not want to do something else.

3
  • 4
    You can use only if without else Commented Dec 15, 2020 at 15:35
  • @JacksonPro, I am very new in python. Actually, I want to run my code under single condition and otherwise it should not do anything. Commented Dec 15, 2020 at 15:36
  • @dimay, Thanks. But what will happen when condition do not meet? Commented Dec 15, 2020 at 15:38

3 Answers 3

5

Don't put else if you don't need it

Sign up to request clarification or add additional context in comments.

1 Comment

you can bypass the code for later use else : pass
1

If you don't want want to do something else, you don't have to use the else part of the statement.

Or you could put

else: None

2 Comments

That's great way! Thanks!!
I'll rather suggest to use else: pass
1

You can either use only if or you can even put else : print("Length is not greater then '0'")

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.