Count-Trailing-Zeros(x) --- Can I use Log(x) to see if X is equal to ( Integer * 10 ^ k) ???

2022-09-19 Thread Hen Hanna
Count how many zeros are at the end of your int: defend_zeros(num): s = str(num) return len(s) - len(s.rstrip("0")) print(end_zeros(10)) # == 1 print(end_zeros(101)) # == 0 print(end

Re: count consecutive elements

2021-09-27 Thread Bischoop
I'd wish to have this challenge posted on my blog but because I suck in IT english, could you guys help me with decribing the task of what the code supposed to do? -- Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Python cannot count apparently

2021-02-08 Thread Michael F. Stemper
On 08/02/2021 13.12, Schachner, Joseph wrote: This code works: mystr = "hello" for ch in mystr: print(ch, end="") result is: hello Note that the for loop does not use range. Strings are iterable, that is they support Python's iteration protocol. So, for ch in mystr: assign

RE: Python cannot count apparently

2021-02-08 Thread Schachner, Joseph
-Original Message- From: Michael F. Stemper Sent: Monday, February 8, 2021 9:19 AM To: python-list@python.org Subject: Re: Python cannot count apparently On 07/02/2021 13.34, Philipp Daher wrote: > Hello, > > I recently coded this snippet of code: > myString=„hello“ &g

Re: Python cannot count apparently

2021-02-08 Thread Michael F. Stemper
On 07/02/2021 13.34, Philipp Daher wrote: Hello, I recently coded this snippet of code: myString=„hello“ for i in range(len(myString): print(string[i]) And now for the weird part: SOMETIMES, the output is this: hello Strange. When I fix the errors in what you posted: - wrong character

Re: Python cannot count apparently

2021-02-07 Thread Peter Pearson
On Sun, 7 Feb 2021 20:49:52 + (UTC), Kevin M. Wilson wrote: > Set i = 0 at the begin of the code, that way each entry starts at > Logical 0 of the array/container/list... No. The original code, as posted, was >>I recently coded this snippet of code: >>myString=„hello“ >>for i in

Re: Python cannot count apparently

2021-02-07 Thread dn via Python-list
On 08/02/2021 09.49, Kevin M. Wilson via Python-list wrote: > Set i = 0 at the begin of the code, that way each entry starts at Logical 0 > of the array/container/list... FYI: https://docs.python.org/3/library/stdtypes.html#typesseq-range See also @Chris' contribution regarding the pythonic idi

Re: Python cannot count apparently

2021-02-07 Thread Kevin M. Wilson via Python-list
Set i = 0 at the begin of the code, that way each entry starts at Logical 0 of the array/container/list... "The only way to have experience is by having the experience"! On Sunday, February 7, 2021, 12:56:40 PM MST, Karsten Hilbert wrote: Am Sun, Feb 07, 2021 at 07:47:03PM + schr

Re: Python cannot count apparently

2021-02-07 Thread Karsten Hilbert
Am Sun, Feb 07, 2021 at 07:47:03PM + schrieb Paul Bryan: > That's not the only problem with the code. There's a missing close- > paren and a reference to "string" which I presume was meant to be > "myString". I know. I wasn't going to spoil everything right away. The sort of response we would

Re: Python cannot count apparently

2021-02-07 Thread Paul Bryan
That's not the only problem with the code. There's a missing close- paren and a reference to "string" which I presume was meant to be "myString". Suggest OP create a reproducible case, and paste the code and output verbatim. On Sun, 2021-02-07 at 20:40 +0100, Karsten Hilbert wrote: > Am Sun, Feb

Re: Python cannot count apparently

2021-02-07 Thread Joel Goldstick
On Sun, Feb 7, 2021 at 2:36 PM Philipp Daher via Python-list wrote: > > Hello, > > I recently coded this snippet of code: > myString=„hello“ > for i in range(len(myString): > print(string[i]) > > And now for the weird part: > > SOMETIMES, the output is this: > > hello > > And SOMETIMES, the o

Re: Python cannot count apparently

2021-02-07 Thread Chris Angelico
On Mon, Feb 8, 2021 at 6:36 AM Philipp Daher via Python-list wrote: > > Hello, > > I recently coded this snippet of code: > myString=„hello“ > for i in range(len(myString): > print(string[i]) This code won't work as is. Please *copy and paste* your code when asking for help. > And now for t

Re: Python cannot count apparently

2021-02-07 Thread Karsten Hilbert
Am Sun, Feb 07, 2021 at 08:34:34PM +0100 schrieb Philipp Daher via Python-list: > I recently coded this snippet of code: > myString=„hello“ I doubt you have (coded *this* snippet of code) -- because those quotes wouldn't work. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B --

Python cannot count apparently

2021-02-07 Thread Philipp Daher via Python-list
Hello, I recently coded this snippet of code: myString=„hello“ for i in range(len(myString): print(string[i]) And now for the weird part: SOMETIMES, the output is this: hello And SOMETIMES, the output changes to: ohell WHY??? Why do I get different outputs with the EXACT SAME CODE? Can

Re: count consecutive elements

2021-01-19 Thread Peter Otten
ch I can append character if not in lil. How often does Tim's solution? oh here Im stuck and dont understand what you mean? [Tim Chase] def consecutive_counter(seq): # I'm not sure if there's something # like this already in itertools cur = nada = objec

Re: count consecutive elements

2021-01-19 Thread Bischoop
On 2021-01-19, Peter Otten <__pete...@web.de> wrote: > On 19/01/2021 04:45, Bischoop wrote: > >> I sat to it again and solved it. > > Congratulations! > > > lil = tuple(set(s)) # list of characters in s > > > > li=[0,0,0,0,0,0] # list for counted repeats > > I see a minor problem here. What happen

Re: count consecutive elements

2021-01-19 Thread Peter Otten
On 19/01/2021 04:45, Bischoop wrote: I sat to it again and solved it. Congratulations! > lil = tuple(set(s)) # list of characters in s > > li=[0,0,0,0,0,0] # list for counted repeats I see a minor problem here. What happens if s contains more than len(li) characters? import timeit Since

Re: count consecutive elements

2021-01-18 Thread Bischoop
On 2021-01-14, Stefan Ram wrote: > > If you want to know why, maybe you should insert print > statements to see the values of critical variables and > expression, especially in loops. > > Then compare the printed values with your expectations. > > Also, decompose into meaningful functio

Re: count consecutive elements

2021-01-17 Thread Peter Otten
way to spell this? if not string: return (0, []) grouped = itertools.groupby(string) grouped_with_lengths = [(len(list(value)), key) for key, value in grouped] max_count_and_letter = max(grouped_with_lengths) max_count = max_count_and_letter[0] result = (ma

Re: count consecutive elements

2021-01-16 Thread Dan Stromberg
typing.Tuple[int, typing.List[str]]: """Get the longest run of a single consecutive character.""" if not string: return (0, []) grouped = itertools.groupby(string) grouped_with_lengths = [(len(list(value)), key) for key, value in gr

Re: count consecutive elements

2021-01-15 Thread Tim Chase
On 2021-01-16 03:32, Bischoop wrote: >> The OP didn't specify what should happen in that case, so it would >> need some clarification. > > In that case maybe good solution would be to return three of them? That's the solution I chose in my initial reply, you get a tuple back of ([list of longest

Re: count consecutive elements

2021-01-15 Thread Bischoop
On 2021-01-14, Tim Chase wrote: > > seems to only return one value so seems to get odd results if I > specify something like > > get_longest("aaabcccbbb") > > which at least here tells me that "c" is the longest run, even though > aaa, bbb, and ccc are all runs of length 3. The OP didn't specif

Re: count consecutive elements

2021-01-14 Thread Wolfram Hinderer via Python-list
Am 13.01.2021 um 22:20 schrieb Bischoop: I want to to display a number or an alphabet which appears mostly consecutive in a given string or numbers or both Examples s= ' aabskaaabad' output: c # c appears 4 consecutive times 8bbakebaoa output: b #b appears 2 consecutive times You can

Re: count consecutive elements

2021-01-14 Thread Bischoop
On 2021-01-13, Bischoop wrote: I know what was wrong: > m = s.index(i) I forgot that m will return first index of i. So tried that way but still getting out of index although I that that I'm making sure not to get out of index. s = 'aabskaaabadh' c = 0 t = list(set(s)) # list

Re: count consecutive elements

2021-01-14 Thread Dan Stromberg
On Wed, Jan 13, 2021 at 6:20 PM Dan Stromberg wrote: > On Wed, Jan 13, 2021 at 5:59 PM Tim Chase > wrote: > >> On 2021-01-13 21:20, Bischoop wrote: >> > I want to to display a number or an alphabet which appears mostly >> > consecutive in a given string or numbers or both >> > Examples >> > s=

Re: count consecutive elements

2021-01-13 Thread Tim Chase
On 2021-01-13 18:20, Dan Stromberg wrote: > I'm kind of partial to: > > import collections > import typing > > > def get_longest(string: str) -> typing.Tuple[int, str]: > """Get the longest run of a single consecutive character.""" > dict_: typing.DefaultDict[str, int] = > collections.de

Re: count consecutive elements

2021-01-13 Thread Dan Stromberg
On Wed, Jan 13, 2021 at 5:59 PM Tim Chase wrote: > On 2021-01-13 21:20, Bischoop wrote: > > I want to to display a number or an alphabet which appears mostly > > consecutive in a given string or numbers or both > > Examples > > s= ' aabskaaabad' > > output: c > > # c appears 4 consecutive ti

Re: count consecutive elements

2021-01-13 Thread Tim Chase
b > #b appears 2 consecutive times I'd break the problem into two parts: 1) iterate over your thing (in this case, a string) and emit the item and its correpsonding count of consecutive matches. 2) feed that into something that finds the longest run(s) output by that. So off the cuff, som

Re: count consecutive elements

2021-01-13 Thread Bischoop
On 2021-01-13, Bischoop wrote: > t = set(s) # set of characters in s I have this one changed to: t= list(set(s)) -- https://mail.python.org/mailman/listinfo/python-list

count consecutive elements

2021-01-13 Thread Bischoop
d for each element loop the string to check if equal with element set element if so count =+1 and check if next to it is not equal add counter value to list with same index as in set. However I'm fighting to code it and the counting numbers are not right: s = 'aabskaaabad' c = 0 t = s

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-15 Thread sjeik_appie
On 15 Apr 2020 10:28, Peter Otten <__pete...@web.de> wrote: sjeik_ap...@hotmail.com wrote: >    On 12 Apr 2020 12:30, Peter Otten <__pete...@web.de> wrote: > >  Rahul Gupta wrote: > >  >for line in enumerate(csv_reader): >  >print(line[csv_reader.

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-15 Thread Peter Otten
sjeik_ap...@hotmail.com wrote: >On 12 Apr 2020 12:30, Peter Otten <__pete...@web.de> wrote: > > Rahul Gupta wrote: > > >for line in enumerate(csv_reader): > >print(line[csv_reader.fieldnames[1]]) > > enumerate() generates (index, line) tuples that you need to unpack: >

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-14 Thread sjeik_appie
On 12 Apr 2020 12:30, Peter Otten <__pete...@web.de> wrote: Rahul Gupta wrote: > for line in enumerate(csv_reader): > print(line[csv_reader.fieldnames[1]]) enumerate() generates (index, line) tuples that you need to unpack:     for index, line in enumerat

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Rahul Gupta
@Peter Thanks alot -- https://mail.python.org/mailman/listinfo/python-list

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Peter Otten
track of the row count you can modify the above like so: row_count = 0 for row_count, line in enumerate(csv_reader, 1): print(line[csv_reader.fieldnames[1]]) -- https://mail.python.org/mailman/listinfo/python-list

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Rahul Gupta
import csv import numpy as np with open("D:\PHD\obranking\\cell_split_demo.csv", mode='r') as csv_file: csv_reader = csv.DictReader(csv_file) print(csv_reader.fieldnames) col_count = print(len(csv_reader.fieldnames)) #print(sum(1 for row in csv_file)) row_count = 0

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Peter Otten
Rahul Gupta wrote: > On Sunday, April 12, 2020 at 1:35:10 PM UTC+5:30, Rahul Gupta wrote: >> the cells in my csv that i wrote looks likes this >> ['82#201#426#553#602#621#811#908#1289#1342#1401#1472#1593#1641#1794#2290#2341#2391#3023#3141#3227#3240#3525#3529#3690#3881#4406#4421#4497#4719#4722#492

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Rahul Gupta
On Sunday, April 12, 2020 at 1:35:10 PM UTC+5:30, Rahul Gupta wrote: > the cells in my csv that i wrote looks likes this > ['82#201#426#553#602#621#811#908#1289#1342#1401#1472#1593#1641#1794#2290#2341#2391#3023#3141#3227#3240#3525#3529#3690#3881#4406#4421#4497#4719#4722#4920#5053#5146#5433'] > and

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Peter Otten
Rahul Gupta wrote: > the cells in my csv that i wrote looks likes this > ['82#201#426#553#602#621#811#908#1289#1342#1401#1472#1593#1641#1794#2290#2341#2391#3023#3141#3227#3240#3525#3529#3690#3881#4406#4421#4497#4719#4722#4920#5053#5146#5433'] > and the cells which are empty looks like [''] i have

i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Rahul Gupta
the cells in my csv that i wrote looks likes this ['82#201#426#553#602#621#811#908#1289#1342#1401#1472#1593#1641#1794#2290#2341#2391#3023#3141#3227#3240#3525#3529#3690#3881#4406#4421#4497#4719#4722#4920#5053#5146#5433'] and the cells which are empty looks like [''] i have tried the following code

Re: Get Count of function arguments passed in

2019-09-11 Thread Roel Schroeven
Sayth Renshaw schreef op 11/09/2019 om 12:11: I want to allow as many lists as needed to be passed into a function. But how can I determine how many lists have been passed in? I expected this to return 3 but it only returned 1. matrix1 = [[1, -2], [-3, 4],] matrix2 = [[2, -1], [0, -1]] matrix3

Re: Get Count of function arguments passed in

2019-09-11 Thread David Lowry-Duda
> I expected this to return 3 but it only returned 1. > > matrix1 = [[1, -2], [-3, 4],] > matrix2 = [[2, -1], [0, -1]] > matrix3 = [[2, -1], [0, -1]] > > def add(*matrix): > print(len(locals())) > > print(add(matrix1, matrix2)) In this case, locals will be a dictionary with exactly one key.

Re: Get Count of function arguments passed in

2019-09-11 Thread ast
Le 11/09/2019 à 12:11, Sayth Renshaw a écrit : Hi I want to allow as many lists as needed to be passed into a function. But how can I determine how many lists have been passed in? I expected this to return 3 but it only returned 1. matrix1 = [[1, -2], [-3, 4],] matrix2 = [[2, -1], [0, -1]] mat

Re: Get Count of function arguments passed in

2019-09-11 Thread Sayth Renshaw
On Wednesday, 11 September 2019 20:25:32 UTC+10, Sayth Renshaw wrote: > On Wednesday, 11 September 2019 20:11:21 UTC+10, Sayth Renshaw wrote: > > Hi > > > > I want to allow as many lists as needed to be passed into a function. > > But how can I determine how many lists have been passed in? > >

Re: Get Count of function arguments passed in

2019-09-11 Thread Sayth Renshaw
On Wednesday, 11 September 2019 20:11:21 UTC+10, Sayth Renshaw wrote: > Hi > > I want to allow as many lists as needed to be passed into a function. > But how can I determine how many lists have been passed in? > > I expected this to return 3 but it only returned 1. > > matrix1 = [[1, -2], [-3,

Get Count of function arguments passed in

2019-09-11 Thread Sayth Renshaw
Hi I want to allow as many lists as needed to be passed into a function. But how can I determine how many lists have been passed in? I expected this to return 3 but it only returned 1. matrix1 = [[1, -2], [-3, 4],] matrix2 = [[2, -1], [0, -1]] matrix3 = [[2, -1], [0, -1]] # print(add(matrix1, ma

Re: how to get INDEX count, or last number of Index

2018-05-24 Thread bartc
On 24/05/2018 03:37, Terry Reedy wrote: On 5/23/2018 8:46 PM, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, U

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Terry Reedy
On 5/23/2018 8:46 PM, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the same as len(s)-1 but

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Cameron Simpson
On 23May2018 23:14, Mark Lawrence wrote: On 23/05/18 22:56, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index Not sure

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 24/05/2018 01:46, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the same as len(s)-1 but f

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the same as len(s)-1 but faster. This illustrates one probl

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Terry Reedy
On 5/23/2018 6:07 PM, asa32s...@gmail.com wrote: On Wednesday, May 23, 2018 at 5:51:42 PM UTC-4, asa3...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index thanks thanks, it

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Terry Reedy
On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the same as len(s)-1 but faster. >>> s = 'kitty' >>> s[len(s)-1] 'y' >>> s[-1] 'y' -- Terry Jan Ree

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Mark Lawrence
On 23/05/18 22:56, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index thanks Not sure I'm following your question; len(s

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread asa32sd23
On Wednesday, May 23, 2018 at 5:51:42 PM UTC-4, asa3...@gmail.com wrote: > s = "kitti" > > 0,1,2,3,4 > k,i,t,t,i > > how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a > function that gives me last number of index > > thanks thanks, it seems just a len(s) -1 is the righ

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 23/05/2018 22:51, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index Not for that trivial task. But you can create your own: def upb(x): return len(x)-1 # '

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread asa32sd23
On Wednesday, May 23, 2018 at 5:56:26 PM UTC-4, Rob Gaddi wrote: > On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: > > s = "kitti" > > > > 0,1,2,3,4 > > k,i,t,t,i > > > > how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a > > function that gives me last number of index

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Rob Gaddi
On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index thanks Not sure I'm following your question; len(s)-1 is much faster than enumerating o

how to get INDEX count, or last number of Index

2018-05-23 Thread asa32sd23
s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: While, If, Count Statements

2017-11-28 Thread Cai Gengyang
;while" loop > > > > > > Have you tried putting the 'if' statement inside the 'while' loop? > > > > > > If not, give it a shot and see what happens. > > > > > > Frank Millman > > > > I tried this : > > &g

Re: While, If, Count Statements

2017-11-28 Thread Frank Millman
t; > > Sure, so how would the code look like if I want the "if" statement to > > be > > nested inside the "while" loop > > Have you tried putting the 'if' statement inside the 'while' loop? > > If not, give it a shot and see wh

Re: While, If, Count Statements

2017-11-28 Thread Cai Gengyang
nested inside the "while" loop > > Have you tried putting the 'if' statement inside the 'while' loop? > > If not, give it a shot and see what happens. > > Frank Millman I tried this : count = 0 while count < 10: if count < 5: prin

Re: While, If, Count Statements

2017-11-28 Thread Frank Millman
"Cai Gengyang" wrote in message news:c2dfc9c4-3e16-480c-aebf-553081775...@googlegroups.com... Sure, so how would the code look like if I want the "if" statement to be nested inside the "while" loop Have you tried putting the 'if' statement inside the 'while' loop? If not, give it a shot and

Re: While, If, Count Statements

2017-11-28 Thread Cai Gengyang
On Tuesday, November 28, 2017 at 6:09:17 AM UTC+8, Ned Batchelder wrote: > On 11/27/17 7:54 AM, Cai Gengyang wrote: > > Input : > > > > count = 0 > > > > if count < 5: > > print "Hello, I am an if statement and count is", count > > &

While, If, Count Statements

2017-11-27 Thread nospam . Cai Gengyang
Input : count = 0 if count < 5: print "Hello, I am an if statement and count is", count while count < 10: print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I

Re: While, If, Count Statements

2017-11-27 Thread nospam . Ned Batchelder
On 11/27/17 7:54 AM, Cai Gengyang wrote: > Input : > > count = 0 > > if count < 5: >print "Hello, I am an if statement and count is", count > > while count < 10: > print "Hello, I am a while and count is", count >count += 1 >

Re: While, If, Count Statements

2017-11-27 Thread nospam . bartc
On 27/11/2017 12:54, Cai Gengyang wrote: > > Input : > > count = 0 > > if count < 5: >print "Hello, I am an if statement and count is", count > > while count < 10: >print "Hello, I am a while and count is", count >count += 1

Re: While, If, Count Statements

2017-11-27 Thread Stefan Ram
Cai Gengyang writes: Statement 0: >count = 0 Statement 1: >if count < 5: > print "Hello, I am an if statement and count is", count Statement 2: >while count < 10: > print "Hello, I am a while and count is", count > count += 1 There are

Re: While, If, Count Statements

2017-11-27 Thread Ned Batchelder
On 11/27/17 7:54 AM, Cai Gengyang wrote: Input : count = 0 if count < 5: print "Hello, I am an if statement and count is", count while count < 10: print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is

Re: While, If, Count Statements

2017-11-27 Thread bartc
On 27/11/2017 12:54, Cai Gengyang wrote: Input : count = 0 if count < 5: print "Hello, I am an if statement and count is", count while count < 10: print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is

While, If, Count Statements

2017-11-27 Thread Cai Gengyang
Input : count = 0 if count < 5: print "Hello, I am an if statement and count is", count while count < 10: print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-16 Thread Peter Otten
Andre Müller wrote: > # to impress your friends you can do > for chunk in itertools.zip_longest(*[iter(s)]*4): > chunked_str = ''.join(c for c in chunk if c) # generator expression > inside join with condition > print(chunked_str) This can be simplified with a fillvalue >>> s = "abracad

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-16 Thread Andre Müller
Am 15.06.2017 um 07:09 schrieb Jussi Piitulainen: > Andre Müller writes: > >> I'm a fan of infinite sequences. Try out itertools.islice. >> You should not underestimate this very important module. >> >> Please read also the documentation: >> https://docs.python.org/3.6/library/itertools.html >> >>

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Jussi Piitulainen
Andre Müller writes: > I'm a fan of infinite sequences. Try out itertools.islice. > You should not underestimate this very important module. > > Please read also the documentation: > https://docs.python.org/3.6/library/itertools.html > > from itertools import islice > > iterable = range(10

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Andre Müller
I'm a fan of infinite sequences. Try out itertools.islice. You should not underestimate this very important module. Please read also the documentation: https://docs.python.org/3.6/library/itertools.html from itertools import islice iterable = range(100) # since Python 3 range is a lazy e

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Malcolm Greene
Thank you Peter and Jussi - both your solutions were very helpful! Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Jussi Piitulainen
Malcolm Greene writes: > Wondering if there's a standard lib version of something like > enumerate() that takes a max count value? > Use case: When you want to enumerate through an iterable, but want to > limit the number of iterations without introducing if-condition-break

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Peter Otten
Malcolm Greene wrote: > Wondering if there's a standard lib version of something like > enumerate() that takes a max count value? > Use case: When you want to enumerate through an iterable, but want to > limit the number of iterations without introducing if-condition-break

Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Malcolm Greene
Wondering if there's a standard lib version of something like enumerate() that takes a max count value? Use case: When you want to enumerate through an iterable, but want to limit the number of iterations without introducing if-condition-break blocks in code. Something like: for counter, k

Re: Rosetta: Count in factors

2017-04-30 Thread alister
On Sat, 29 Apr 2017 22:05:16 +, Robert L. wrote: >> Task >> >> Write a program which counts up from 1, displaying each number as the >> multiplication of its prime factors. >> >> For the purpose of this task, 1 (unity) may be shown as itself. >> >> >> Example >> >>2 is prime, so i

Re: count points where is within the polygons using shapely and fiona

2017-01-30 Thread Xristos Xristoou
tell your proposal to count -- https://mail.python.org/mailman/listinfo/python-list

Re: count points where is within the polygons using shapely and fiona

2017-01-29 Thread Peter Pearson
On Sun, 29 Jan 2017 11:42:47 -0800 (PST), Xristos Xristoou wrote: > i tried to count points from the point shapefile where is within in > the polygon shapefile but i fail.Maybe my code is complete wrong but i > tried. > any idea how to fix my code ? > i want fast method because

count points where is within the polygons using shapely and fiona

2017-01-29 Thread Xristos Xristoou
i tried to count points from the point shapefile where is within in the polygon shapefile but i fail.Maybe my code is complete wrong but i tried. any idea how to fix my code ? i want fast method because i have big data features from shapely.geometry import shape import fiona filepath1

Re: Use pyodbc to count and list tables, columns, indexes, etc

2016-03-31 Thread DFS
On 3/31/2016 11:44 PM, DFS wrote: import pyodbc dbName = "D:\test_data.mdb" conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+dbName) cursor = conn.cursor() #COUNT TABLES, LIST COLUMNS tblC

Use pyodbc to count and list tables, columns, indexes, etc

2016-03-31 Thread DFS
import pyodbc dbName = "D:\test_data.mdb" conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+dbName) cursor = conn.cursor() #COUNT TABLES, LIST COLUMNS tblCount = 0 for rows in cursor.

Re: Read and count

2016-03-10 Thread Val Krem via Python-list
Thank you very much for the help. First I want count by city and year. City year count Xc1.2001. 1 Xc1.2002. 3 Yv1. 2001. 1 Yv2.2002. 4 This worked fine ! Now I want to count by city only City. Count Xc1. 4 Yv2. 5 Then combine these two objects with the original data and

RE: Read and count

2016-03-10 Thread Joaquin Alzola
alf Of Val Krem via Python-list Sent: 09 March 2016 21:31 To: python-list@python.org Subject: Read and count Hi all, I am a new learner about python (moving from R to python) and trying read and count the number of observation by year for each city. The data set look like city year x XC1 200

Re: Read and count

2016-03-10 Thread Peter Otten
Jussi Piitulainen wrote: > Val Krem writes: > >> Hi all, >> >> I am a new learner about python (moving from R to python) and trying >> read and count the number of observation by year for each city. >> >> >> The data set look like >> ci

Re: Read and count

2016-03-10 Thread Mark Lawrence
Hello and welcome. Please see my comments below. On 09/03/2016 21:30, Val Krem via Python-list wrote: Hi all, I am a new learner about python (moving from R to python) and trying read and count the number of observation by year for each city. The data set look like city year x XC1 2001

Re: Read and count

2016-03-10 Thread Jussi Piitulainen
Val Krem writes: > Hi all, > > I am a new learner about python (moving from R to python) and trying > read and count the number of observation by year for each city. > > > The data set look like > city year x > > XC1 2001 10 > XC1 2001 20 > XC1 2002

Read and count

2016-03-10 Thread Val Krem via Python-list
Hi all, I am a new learner about python (moving from R to python) and trying read and count the number of observation by year for each city. The data set look like city year x XC1 2001 10 XC1 2001 20 XC1 2002 20 XC1 2002 10 XC1 2002 10 Yv2 2001 10 Yv2 2002 20 Yv2 2002

Re: How can I count word frequency in a web site?

2015-11-30 Thread ryguy7272
On Sunday, November 29, 2015 at 9:51:46 PM UTC-5, Laura Creighton wrote: > In a message of Sun, 29 Nov 2015 21:31:49 -0500, Cem Karan writes: > >You might want to look into Beautiful Soup > >(https://pypi.python.org/pypi/beautifulsoup4), which is an HTML > >screen-scraping tool. I've never used

Re: How can I count word frequency in a web site?

2015-11-30 Thread ryguy7272
On Sunday, November 29, 2015 at 7:49:40 PM UTC-5, ryguy7272 wrote: > I'm trying to figure out how to count words in a web site. Here is a sample > of the link I want to scrape data from and count specific words. > http://finance.yahoo.com/q/h?s=STRP+Headlines > > I only w

Re: How can I count word frequency in a web site?

2015-11-29 Thread Michiel Overtoom
> On 30 Nov 2015, at 03:54, ryguy7272 wrote: > > Now, how can I count specific words like 'fraud' and 'lawsuit'? - convert the page to plain text - remove any interpunction - split into words - see what words occur - enumerate all the words and increase a counter

Re: How can I count word frequency in a web site?

2015-11-29 Thread ryguy7272
> Good luck, > Cem Karan > > On Nov 29, 2015, at 7:49 PM, ryguy7272 wrote: > > > I'm trying to figure out how to count words in a web site. Here is a > > sample of the link I want to scrape data from and count specific words. > > http://finance.yahoo.com/q/h?s=S

Re: How can I count word frequency in a web site?

2015-11-29 Thread Laura Creighton
In a message of Sun, 29 Nov 2015 21:31:49 -0500, Cem Karan writes: >You might want to look into Beautiful Soup >(https://pypi.python.org/pypi/beautifulsoup4), which is an HTML >screen-scraping tool. I've never used it, but I've heard good things about it. > >Good luck, >Cem Karan http://coderev

Re: How can I count word frequency in a web site?

2015-11-29 Thread Cem Karan
figure out how to count words in a web site. Here is a sample > of the link I want to scrape data from and count specific words. > http://finance.yahoo.com/q/h?s=STRP+Headlines > > I only want to count certain words, like 'fraud', 'lawsuit', etc. I want to > have

How can I count word frequency in a web site?

2015-11-29 Thread ryguy7272
I'm trying to figure out how to count words in a web site. Here is a sample of the link I want to scrape data from and count specific words. http://finance.yahoo.com/q/h?s=STRP+Headlines I only want to count certain words, like 'fraud', 'lawsuit', etc. I want to

Re: Simplest/Idiomatic way to count files in a directory (using pathlib)

2015-06-23 Thread Terry Reedy
On 6/22/2015 9:32 PM, Paul Rubin wrote: Travis Griggs writes: The following seems to obtuse/clever for its own good: return sum(1 for _ in self.path.iterdir()) I disagree. For one who understands counting and Python, this is a direct way to define the count of a finite iterable. A

Re: Simplest/Idiomatic way to count files in a directory (using pathlib)

2015-06-23 Thread Peter Otten
Travis Griggs wrote: > Subject nearly says it all. > > If i’m using pathlib, what’s the simplest/idiomatic way to simply count > how many files are in a given directory? > > I was surprised (at first) when > > len(self.path.iterdir()) > > I don’t say anythin

  1   2   3   4   5   6   >