hey everyone,
i'm going to be comparing data in a list. Just basic >= or <= type stuff.
However, the list i have somtimes starts with 'n/a'. That is somtimes it starts like this:
data = ['1.0', '2.0', '1.5']
or
data = ['n/a', '1.0', '2.0', '1.5']
or
data = ['n/a', 'n/a', '1.0', '2.0', '1.5']
so i thought i could do something like this. so that I can start comparing actual numbers vs each other... - >>> for i in x:
-
... if i == 'n/a':
-
... x.remove(i)
Should I just throw that bit in the code twice, back to back, in case i get a data list like the 3rd one (the oen w/ 2 n/a's) or does anyone have a more enlightened idea?
thanks
1 1321 bvdet 2,851
Recognized Expert Moderator Specialist
hey everyone,
i'm going to be comparing data in a list. Just basic >= or <= type stuff.
However, the list i have somtimes starts with 'n/a'. That is somtimes it starts like this:
data = ['1.0', '2.0', '1.5']
or
data = ['n/a', '1.0', '2.0', '1.5']
or
data = ['n/a', 'n/a', '1.0', '2.0', '1.5']
so i thought i could do something like this. so that I can start comparing actual numbers vs each other... - >>> for i in x:
-
... if i == 'n/a':
-
... x.remove(i)
Should I just throw that bit in the code twice, back to back, in case i get a data list like the 3rd one (the oen w/ 2 n/a's) or does anyone have a more enlightened idea?
thanks
Here's a couple of options: - >>> data = ['n/a', 'n/a', '1.0', '2.0', '1.5']
-
>>> if 'n/a' in data:
-
... data = [item for item in data if item != 'n/a']
-
...
-
>>> data
-
['1.0', '2.0', '1.5']
-
>>> data = ['n/a', 'n/a', '1.0', '2.0', '1.5']
-
>>> while 'n/a' in data:
-
... data.remove('n/a')
-
...
-
>>> data
-
['1.0', '2.0', '1.5']
-
>>>
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Peter |
last post by:
Hi
how can I compare two byte arrays in VB.NET
Thank
Peter
|
by: Odd-R. |
last post by:
I have to lists, A and B, that may, or may not be equal. If they are not
identical, I want the output to be three new lists, X,Y and Z where X has
all the elements that are in A, but not in B, and Y contains all the
elements that are B but not in A. Z will then have the elements that are
in both A and B.
One way of doing this is of course to iterate throug the lists and compare
each of the element, but is there a more efficient way?
...
|
by: Manny Chohan |
last post by:
Hi, i have two datetime values in format 11/22/04 9:00 AM and 11/22/04 9:30
AM. How can i compare dates .net c# or if there is any other way such as
Javascript.
Thanks
Manny
|
by: Will Chamberlain |
last post by:
I just created an application that displays data from 2 sources in a
datagrid. There are 2 repeaters nested in the datagrid (probably not the
best idea). The whole purpose of this application is to visually display
side-by-side data from these 2 sources so that the end-user can track
changes. What I am wanting to do now is to highlight, bold, etc... rows
where values are different.
Layout (currently have):
Column1(product) / Column2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |