473,626 Members | 3,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What are the syntax for &&, ||

RC

if condition1 && condition2: # and
doThis
elif condition3 || condition4: # or
doThat

In most of language have &&, ||

How do I do in Python?
Oct 22 '08 #1
2 1476
RC wrote:
if condition1 && condition2: # and
Â*Â*Â*Â*Â*Â*Â*Â *doThis
elif condition3 || condition4: # or
Â*Â*Â*Â*Â*Â*Â*Â *doThat
In most of language have &&, ||

How do I do in Python?
if condition1 and condition2: # &&
Â*Â*Â*Â*Â*Â*Â*Â *doThis
elif condition3 or condition4: # ||
Â*Â*Â*Â*Â*Â*Â*Â *doThat

See the pattern?
Oct 22 '08 #2
if condition1 && condition2: # and
doThis
elif condition3 || condition4: # or
doThat

In most of language have &&, ||

How do I do in Python?
Heh, you answered your own question in your comments:

if condition1 and condition2:
doThis()
elif cond3 or cond4:
doThat()

-tkc

Oct 22 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
5664
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've reduced my form request to a simple text string entry, instead of my desired optional parameters. As i have been stuck with a single unfathomable glitch for over a year. Basically, if i enter queries such as ; "select * from table" "select * from...
4
3703
by: MS | last post by:
Just a general question here re VBA. Can anyone explain the differences between "!" and "." when refering to a control? eg Me!TxtBox and Me.TxtBox. What is difference between "+" and "&" when working with strings. eg MyStr = "I have " & MyNumber & " apples." and MyStr = "I have " + MyNumber + " apples."
4
1896
by: Joel | last post by:
Run this method: public void test() { bool b; int i=0; b=false; i=0; b=(b && i++==1);
4
2113
by: Peter Oliphant | last post by:
I've upgraded my code to VS C++.NET 2005 (Express) using /clr pure. My question is, why is there an exception to the rule in how pointer syntax is done in the event handlers? For example, why is this proper syntax: button->Click += gcnew EventHandler( this, &MyClass::MouseHandler ) ; The '&' seems like a hold over from the old syntax, except this is the NEW syntax (i.e., it never wanted the '&' before 2005 at all). Why was the '&'
9
4691
by: Let_Me_Be | last post by:
Hi all, I'm developing a small defensive programming toolkit for my own projects. So, here are my questions. 1) Is it possible to move from something like this: SAFECALL(foo();) to __safecall foo(); 2) I need to auto-add code to every method of particular class safeclass MyClass {
13
2794
by: Ragnar | last post by:
Hi, 2 issues left with my tidy-work: 1) Tidy transforms a "&amp;" in the source-xml into a "&" in the tidied version. My XML-Importer cannot handle it 2) in a long <title>-string a wrap is produced like: <title>my very long title blab la blab la Blabla bla </title> Importer also has got problems with it
0
6733
by: Vijay | last post by:
Prep Courses for International Certifications, CSTE & CSQA & ISEB & ISTQB &Business Analyst & SOA Certifications in HYDERABAD. After receiving overwhelming response to our last 50+ batches, SPECTRAMIND SOLUTIONS now announces a new batch of Prep Courses for CSQA & CSTE& ISEB & ISTQB & Business Analyst & SOA so as to prepare you thoroughly for the most prestigious certification exams conducted by International organizations. We...
18
2381
by: Andrew Wan | last post by:
I have been developing web applications with ASP & Javascript for a long time. I have been using Visual Studio 2003.NET. While VS2003 is okay for intellisense of ASP & Javascript, it's still not that great. One of the cons of ASP & Javascript is that they're both interpreted, which means one has twice the amount of work to do interms of syntax checking & semantic/runtime checking. Another bad thing is that ASP & Javascript doesn't have...
3
2193
by: Tony | last post by:
I see that many pages have &amp; in querystring instead &. What is difference? Can I put page link (url) www.mysite.com/mypage.aspx?lang=EN&ID=15 or I need to write www.mysite.com/mypage.aspx?lang=EN&amp;ID=15 What is difference between & and &amp; and what is better?
1
8366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1812
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.