Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: What's happening here?
Post: RE: What's happening here?
So it's base 2.
This is wrong I'm sure but I'm reading..
1 0 1
2 0 2
= 4
Still looking.. |
|
jesse68 |
General Coding Help |
3 |
1,003 |
Feb-27-2023, 04:11 PM |
|
|
Thread: What's happening here?
Post: What's happening here?
Hi, I'm not understanding what's happening here?
print ( int('101', 2))
# Equals 5However...
print ( int('101))
# Equals 101I guess I don't know what the comma is doing.
Thanks much. |
|
jesse68 |
General Coding Help |
3 |
1,003 |
Feb-27-2023, 03:59 PM |
|
|
Thread: What kind of list is this?
Post: What kind of list is this?
Hi, one more question for the day.
This is a list - my_List = ["one", "two","three"]
This is a dictionary - my_Dict = dict({1: 'Geeks', 2: 'For', 3:'Geeks'})
What is this then? This has multipl... |
|
jesse68 |
General Coding Help |
2 |
1,230 |
Jun-29-2022, 04:25 PM |
|
|
Thread: Finding string in list item
Post: RE: Finding string in list item
Thanks for all of the info, still pretty confusing, it looks like the answer is it just doesn't work that way.
So if it's evaluating an empty string it just ignores it and moves to the OR
print("" ... |
|
jesse68 |
General Coding Help |
8 |
2,019 |
Jun-29-2022, 03:56 PM |
|
|
Thread: Finding string in list item
Post: RE: Finding string in list item
Found it. Have to explicitly specify the list item for each value.
my_list = ["PT300-XXXX", "PB300-XXXX","PB501-XXXX", "PB102-XXXX","AL300-XXXX","BD502-XXXX"]
for node in my_list:
if ('501'in no... |
|
jesse68 |
General Coding Help |
8 |
2,019 |
Jun-29-2022, 03:07 PM |
|
|
Thread: Finding string in list item
Post: RE: Finding string in list item
Yes, I just noticed this.
my_list = ["PT300-XXXX", "PB300-XXXX","PB501-XXXX", "PB102-XXXX","AL300-XXXX","BD502-XXXX"]
for node in my_list:
if ('501' or '502') in node:
print ("HIT")
... |
|
jesse68 |
General Coding Help |
8 |
2,019 |
Jun-29-2022, 03:05 PM |
|
|
Thread: Finding string in list item
Post: Finding string in list item
Hello.
This is odd but I'm sure there is a perfectly good explanation.
Why is "501" and "502" evaluated as true for each item in the list?
my_list = ["PT300-XXXX", "PB300-XXXX","PB501-XXXX", "PB102... |
|
jesse68 |
General Coding Help |
8 |
2,019 |
Jun-29-2022, 02:46 PM |
|
|
Thread: Split Arguments ?
Post: RE: Split Arguments ?
I see it now. Thanks much! |
|
jesse68 |
General Coding Help |
3 |
1,127 |
Jun-24-2022, 03:27 PM |
|
|
Thread: Split Arguments ?
Post: Split Arguments ?
Hi, trying to understand these arguments to this split command which I can't find documented. They may not be related to the split command.
Adding [1::2] to the end of the split. In my example it ap... |
|
jesse68 |
General Coding Help |
3 |
1,127 |
Jun-23-2022, 03:16 PM |
|
|
Thread: Printing through list.. again
Post: RE: Printing through list.. again
@menator01 Thank you. I thought for sure I tried that. I see it clearly now. Thanks |
|
jesse68 |
General Coding Help |
2 |
1,206 |
Apr-16-2022, 03:24 PM |
|
|
Thread: Printing through list.. again
Post: Printing through list.. again
Hi simple help needed please. Just trying to print a specific item in the list. If I iterate through the list I can print each value on a new line. If I try to specify a value in the list it prints a ... |
|
jesse68 |
General Coding Help |
2 |
1,206 |
Apr-16-2022, 03:12 PM |
|
|
Thread: Splitting strings in list of strings
Post: RE: Splitting strings in list of strings
Got it.
result = [ 'val_1: val_2' , 'val_3: val_4' , 'val_5: val_6']
for i in result:
sword = i.split(':')
print (sword[1]) Result:
val_2
val_4
val_6Yes?
Yes! |
|
jesse68 |
General Coding Help |
3 |
1,889 |
Mar-02-2022, 04:48 PM |
|
|
Thread: Splitting strings in list of strings
Post: Splitting strings in list of strings
Hi, trying to figure this one out which I expect should be easy. If I find my own solution before anyone else I'll post it here. I'm looking. Thanks
I have successfully split my line for values that ... |
|
jesse68 |
General Coding Help |
3 |
1,889 |
Mar-02-2022, 04:38 PM |
|
|
Thread: Reading list items without brackets and quotes
Post: RE: Reading list items without brackets and quotes
(Jan-14-2022, 06:58 PM)bowlofred Wrote: The second example is a list. It's a list of strings.
The first one is also a list, but it's list of other lists.
>>> l1 = ["a", "b", "c"]
>>... |
|
jesse68 |
General Coding Help |
6 |
4,826 |
Jan-14-2022, 07:07 PM |
|
|
Thread: Reading list items without brackets and quotes
Post: RE: Reading list items without brackets and quotes
@bowlofred Thanks
I think I got it. So the 2nd example is a list of single strings.
gateways = ["NODE001", "NODE002", "NODE003", "NODE004"]Prints only items..
How would that line be changed so th... |
|
jesse68 |
General Coding Help |
6 |
4,826 |
Jan-14-2022, 07:06 PM |
|
|
Thread: Reading list items without brackets and quotes
Post: RE: Reading list items without brackets and quotes
@ibreeden
Thank you! I kid you not I would pay you right now if I could!
So the second example is NOT a list??
gateways = ["NODE001", "NODE002", "NODE003", "NODE004"]Which results in single items b... |
|
jesse68 |
General Coding Help |
6 |
4,826 |
Jan-14-2022, 06:52 PM |
|
|
Thread: Reading list items without brackets and quotes
Post: Reading list items without brackets and quotes
These brackets and quotes always cause me grief.
If I create the list from reading a csv file then print the list, it prints with brackets.
import csv
with open ('csvtest2.csv','r') as csv_file:
... |
|
jesse68 |
General Coding Help |
6 |
4,826 |
Jan-14-2022, 06:30 PM |