0

How to write long if, else code in python.

Example: if i>="a" and I<="z" or i>="A" and i<="z" I>="0" and <="9" if long how can I write this code.

4th Jun 2021, 3:07 AM
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎ - avatar
8 ответов
+ 4
you could split the condition to many lines if you enclose it in parenthesis (that's also better to put explicit parenthesis to not relly too much on operator precedence in and/or chaining wich could be tricky): if ( ( i >= "a" and I <= "z" ) or ( i >= "A" and i <= "z" ) or ( I >= "0" and <= "9" ) ): pass
4th Jun 2021, 3:45 AM
visph
visph - avatar
+ 1
Use if ,elif,elif,.......else
4th Jun 2021, 3:14 AM
Yash Wable 🇮🇳
Yash Wable 🇮🇳 - avatar
+ 1
visph it's working great
4th Jun 2021, 3:52 AM
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎ - avatar
+ 1
Yash Wable 🇮🇳 if I use if ,elif than My answer print in new line but I want to print in same line.
4th Jun 2021, 4:07 AM
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎ - avatar
+ 1
Yash Wable 🇮🇳 if , else is not good for my case but thanks you tell answer
4th Jun 2021, 4:10 AM
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎ - avatar
0
Let's me try
4th Jun 2021, 3:46 AM
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎ - avatar
0
@Everyone thanks a lot Because of you I could solve sololearn questions.😊😊😊
4th Jun 2021, 5:29 AM
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎ - avatar
0
Also I learned new things in if else statement.
4th Jun 2021, 5:30 AM
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎
𝗣𝗮𝘄𝗮𝗻 𝗞𝘂𝗺𝗮𝗿 🅟︎🅚︎ - avatar