473,386 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Re: Testing for Null?



Alex Bryan wrote:
I am having a problem with a list value that is empty. I have a list of
definitions called mainList. the 5th value in the list doesn't have
anything in it. In this case, the values are definitions; also, in this
case just the word cheese is defined. Here is my output to the console:
5. a sprawling,weedy plant having small lavender or white flowers and
round, flat, segmented fruits thought to resemble little wheels of cheese.
6.
7. an ingot or billet made into a convex, circular form by blows at the
ends.
I've made it so where the numbers, the period, and two spaces follow
that, then the definition. However, as you can see in 6, there is
nothing. Here is the code to print all this:

n=0

for x in mainList:
if mainList[n] == "":
print "Error on this definition"
else:
print str(n+1)+". "+str(mainList[n])
n=n+1

Now the two "" is where I need to figure out if it is empty. What is up
right now doesn't work; or at least doesn't give the desired result. So
I need to know how to write the if statement to make it work. This
should be simple, but I just don't know how to do it, never had this
problem before.
My guess is that your 'empty' value is something like ' ', which is not
equal to ''. Change str to repr and see better what item 6 is.

Jun 29 '08 #1
0 1468

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

Similar topics

6
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start...
7
by: Filips Benoit | last post by:
Hi, TBL_CONTACT_PERSON CNTP_ID (auto) CNTP_LAST_NAME (required = yes) CNTP_FUNCTION (required = no) CNTP_..... (all required = no) FRM_CONTACT_PERSON_ADD_NEW Property DATA ENTRY = YES
19
by: lihua | last post by:
Hi, Group! I got one question here: We all know that fclose() must be called after file operations to avoid unexpected errors.But there are really cases when you forget to do that!Just like...
6
by: Lance | last post by:
Hi, How do you test for an object existing in C#? C# seems to differentiate between 'null' and non-existance. In other languages I could test as so: if(ex.InnerException.StackTrace != null)...
5
by: Brian | last post by:
Hello all.. Am working on an Air Hockey game... have an table loaded into a picture box. The borders of the table are slightly slanted. Am using hit testing lines with GDI+ to manipulate the...
4
by: EL OSO | last post by:
Hi, let's suppose I have a class A { int x; ... public static bool operator == (A a1 , A a2) { return (a1.x==a2.x); }
3
by: Jesper | last post by:
Hi, I've made a class with the following operator overloads listed below. However, If I test a 'pointer' for an instace, I get an exception that the object is not set to an insstance of an...
3
by: tshad | last post by:
I have a query that is returning a null and I am testing for null. The value being sent back is a varChar(11) from Sql Server. If I do the query from Query Analyser I get NULL returned. But if...
11
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at http://groups.google.com/group/comp.lang.javascript/msg/b515a4408680e8e2 I have...
3
by: IanWright | last post by:
I'm currently in the process of writing a class library, and I'm attempting to write as many unit tests as possible to ensure that I can weed out all the mistakes early on. Part of this involves...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.