Nested Loop Code Help

2020-01-26 Thread ferzan saglam
Hello people, I have written the code below which works fine, but it has one 
small problem. Instead of printing one (x) on the first line, it prints two.
I have tried everything in my knowledge, but cannot fix the problem.
Thanks for any help in advance.  


for x in range ( 0, 10):

  stars = 'x'   
  count = 0 

while count < x:
  stars = stars + 'x'   
  count = count + 1 
  print (stars)



Output I am trying to get Output I am getting
x xx
xxxxx
xxx   
  x
x xx
xxxxx
xxx   
  x
x xx
xx
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Nested Loop Code Help

2020-01-26 Thread Dan Purgert
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

ferzan saglam wrote:
> Hello people, I have written the code below which works fine, but it
> has one small problem. Instead of printing one (x) on the first line,
> it prints two.
> I have tried everything in my knowledge, but cannot fix the problem.
> Thanks for any help in advance.  

either take the initial "stars = x" out, or increment stars after you
print it.  Either approach should give you the result you want.

-BEGIN PGP SIGNATURE-

iQEzBAEBCAAdFiEEBcqaUD8uEzVNxUrujhHd8xJ5ooEFAl4tr5sACgkQjhHd8xJ5
ooGt+AgArjEk3CIPLvX36SBhZjnjOCdpTXpvzjZDePgMcAJT3WZTweIVmF+JyV6w
xS7kSI/pjmReP/BTH6XGdcJiqsyKeOh5C1D5HgCYFNsuXcegCd1j7PvKlQ/3tVFz
MZUhT46PtWK04Er/Hj4IHUdvP+IRu5HNeUozcWHPlSV9VJmfOd5e94s/cV7Mx5HA
d1p+GHrhS3VDIqY0MBxm3r9A6ciKjys328YpiUpIRfTIX8uUEYWPhNRr3UcIHLBC
ilgZUV5evyr5CXFIET5UKEw4QD0eMLy3T6o2VqR5HsrgAgFW95RTWXNA+qWw+spV
t/grPnMpZ8Cjw5TTbmFYYIrvEyJ+WQ==
=ern6
-END PGP SIGNATURE-

-- 
|_|O|_| 
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5  4AEE 8E11 DDF3 1279 A281
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Nested Loop Code Help

2020-01-26 Thread ferzan saglam
On Sunday, January 26, 2020 at 3:26:40 PM UTC, Dan Purgert wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
> 
> ferzan saglam wrote:
> > Hello people, I have written the code below which works fine, but it
> > has one small problem. Instead of printing one (x) on the first line,
> > it prints two.
> > I have tried everything in my knowledge, but cannot fix the problem.
> > Thanks for any help in advance.  
> 
> either take the initial "stars = x" out, or increment stars after you
> print it.  Either approach should give you the result you want.
> 
> -BEGIN PGP SIGNATURE-
> 
> iQEzBAEBCAAdFiEEBcqaUD8uEzVNxUrujhHd8xJ5ooEFAl4tr5sACgkQjhHd8xJ5
> ooGt+AgArjEk3CIPLvX36SBhZjnjOCdpTXpvzjZDePgMcAJT3WZTweIVmF+JyV6w
> xS7kSI/pjmReP/BTH6XGdcJiqsyKeOh5C1D5HgCYFNsuXcegCd1j7PvKlQ/3tVFz
> MZUhT46PtWK04Er/Hj4IHUdvP+IRu5HNeUozcWHPlSV9VJmfOd5e94s/cV7Mx5HA
> d1p+GHrhS3VDIqY0MBxm3r9A6ciKjys328YpiUpIRfTIX8uUEYWPhNRr3UcIHLBC
> ilgZUV5evyr5CXFIET5UKEw4QD0eMLy3T6o2VqR5HsrgAgFW95RTWXNA+qWw+spV
> t/grPnMpZ8Cjw5TTbmFYYIrvEyJ+WQ==
> =ern6
> -END PGP SIGNATURE-
> 
> -- 
> |_|O|_| 
> |_|_|O| Github: https://github.com/dpurgert
> |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5  4AEE 8E11 DDF3 1279 A281

Thanks for the help Dan, your suggestion worked.
-- 
https://mail.python.org/mailman/listinfo/python-list


PyQt5 help.

2020-01-26 Thread Souvik Dutta
I am making a birthday reminder app. I want to show tha label (" Today is
Tom's birthday.") Assuming Tom has a birthday.
But I want this label to be visible only when someone has a birthday today.
I am using datetime module to check the date. How can I do this?? Any help
is appreciated.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt5 help.

2020-01-26 Thread Abdur-Rahmaan Janhangeer
suggest a scrollable widget which on loads appends labels with members
birthdays in it.

If 3 members have birthdays today, it will append 3 labels

On Sun, 26 Jan 2020, 21:39 Souvik Dutta,  wrote:

> I am making a birthday reminder app. I want to show tha label (" Today is
> Tom's birthday.") Assuming Tom has a birthday.
> But I want this label to be visible only when someone has a birthday today.
> I am using datetime module to check the date. How can I do this?? Any help
> is appreciated.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Nested Loop Code Help

2020-01-26 Thread Richard Damon

On 1/26/20 10:15 AM, ferzan saglam wrote:

Hello people, I have written the code below which works fine, but it has one 
small problem. Instead of printing one (x) on the first line, it prints two.
I have tried everything in my knowledge, but cannot fix the problem.
Thanks for any help in advance.


for x in range ( 0, 10):

   stars = 'x'  
   count = 0

while count < x: 
   stars = stars + 'x'  
   count = count + 1
   print (stars)



Output I am trying to get Output I am getting
x xx
xxxxx
xxx   
  x
x xx
xxxxx
xxx   
  x
x xx
xx


First skill is to learn to act like an interpreter, and execute the 
instructions one by one.


First we execute the for x in range (0, 10): statement which will set x to 0

Then we set stars to 'x'

Then we set count to 0,

since the while outdents, that ends the loop and we repeat it with x 
having values 1, 2, 3, and up to 9


THEN we go to the bottom loop.

Count is 0, x is 9 so the while is satisfied, so we do a loop

stars = stars + 'x' which is 'xx'

count = count + 1 which is 1

print(stars) prints 'xx'

that ends one pass thru the while loop, so we do the test again

Count is 1, x is 9, so the while is satisfied, so we do a loop,

stars = stars + 'x', which is 'xxx'

count = count + 1, which is 2

print(stars) prints 'xxx'

this continues until count reaches 9 (the value left in x) at which it 
stops.


Thus the loop ran 9 times (for starting values of count = 0, 1, 2, 3, 4, 
5, 6, 7, 8



Think about what you wanted to do and what the code actually did.

The first for x in range (0, 10) doesn't really do what I think you 
wanted, did you mean for the second loop to be nested in it?


If you do nest the second loop, you probably don't want the print at the 
end part of the second loop.


--
Richard Damon

--
https://mail.python.org/mailman/listinfo/python-list


I need help for multidimensional loop

2020-01-26 Thread Growth Hacking Formation
Hi guys,

I need your help please to sold a complicate problem.

It is difficult for me to find the solution but in fact, I am sure it is just a 
few lines of code.

The problem is about some kind of multidimensional loop with some test IF.

I worked hours on it, but I am a newbie and it is too difficult.

I was wondering if a super expert in python could give me a hand.

In order to give a maximum of info (explanations + code + screenshot), I 
prepared a google doc for better understanding. Here in a Facebook post would 
be too hard to read.

https://docs.google.com/document/d/1UQ1-PdU00kQnJCaLJDYHveWyEXLX_5MTv56fwvECb1w/edit?usp=sharing

Thanks for help.

Have a great evening.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I need help for multidimensional loop

2020-01-26 Thread Python

Le 26/01/2020 à 21:36, Growth Hacking Formation a écrit :

Hi guys,

I need your help please to sold a complicate problem.

It is difficult for me to find the solution but in fact, I am sure it is just a 
few lines of code.

The problem is about some kind of multidimensional loop with some test IF.

I worked hours on it, but I am a newbie and it is too difficult.

I was wondering if a super expert in python could give me a hand.

In order to give a maximum of info (explanations + code + screenshot), I 
prepared a google doc for better understanding. Here in a Facebook post would 
be too hard to read.

https://docs.google.com/document/d/1UQ1-PdU00kQnJCaLJDYHveWyEXLX_5MTv56fwvECb1w/edit?usp=sharing

Thanks for help.

Have a great evening.



You are a joke, aren't you?


--
https://mail.python.org/mailman/listinfo/python-list


Re: I need help for multidimensional loop

2020-01-26 Thread pyotr filipivich
Growth Hacking Formation  on Sun, 26
Jan 2020 12:36:05 -0800 (PST) typed in comp.lang.python  the
following:
>Hi guys,
>
>I need your help please to sold a complicate problem.
>
>It is difficult for me to find the solution but in fact, I am sure it is just 
>a few lines of code.
>
>The problem is about some kind of multidimensional loop with some test IF.
>
>I worked hours on it, but I am a newbie and it is too difficult.
>
>I was wondering if a super expert in python could give me a hand.
>
>In order to give a maximum of info (explanations + code + screenshot), I 
>prepared a google doc for better understanding. Here in a Facebook post would 
>be too hard to read.
>
>https://docs.google.com/document/d/1UQ1-PdU00kQnJCaLJDYHveWyEXLX_5MTv56fwvECb1w/edit?usp=sharing
>
>Thanks for help.
>
>Have a great evening.

I realize that if you could explain it well enough for someone
else to realize what your problem is, you should be able to see the
solution yourself.

It would be better if you could provide a short "elevator itch" on
what you're trying to do.

Cause "multidimensional arrays" can get hairy really fast.  I
mean, try building a sieve of erostothenses using arrays in integers
[0..maxint] in size.

-- 
pyotr filipivich
Next month's Panel: Graft - Boon or blessing?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Nested Loop Code Help

2020-01-26 Thread Greg Ewing

On 27/01/20 4:15 am, ferzan saglam wrote:

for x in range ( 0, 10):
   stars = 'x'
   count = 0

By the way, this 'for' loop is unnecessary. The end result is just to
give initial values to three names. You don't need a loop at all for
that, just three assignment statements.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Nested Loop Code Help

2020-01-26 Thread Richard Damon

On 1/26/20 6:11 PM, Greg Ewing wrote:

On 27/01/20 4:15 am, ferzan saglam wrote:

for x in range ( 0, 10):
   stars = 'x'
   count = 0

By the way, this 'for' loop is unnecessary. The end result is just to
give initial values to three names. You don't need a loop at all for
that, just three assignment statements.

His thinking MIGHT have been that this for loop be the main loop that 
prints the 10 lines (i.e the following loop be within this loop). In 
that case, the assignment statements in the loop make sense. In that 
case, the print call wouldn't be in the while loop, which would add x 
'x's to the string.


--
Richard Damon

--
https://mail.python.org/mailman/listinfo/python-list


Re: I need help for multidimensional loop

2020-01-26 Thread DL Neil via Python-list

On 27/01/20 12:08 PM, pyotr filipivich wrote:

Growth Hacking Formation  on Sun, 26
Jan 2020 12:36:05 -0800 (PST) typed in comp.lang.python  the
following:

Hi guys,

I need your help please to sold a complicate problem.

It is difficult for me to find the solution but in fact, I am sure it is just a 
few lines of code.

The problem is about some kind of multidimensional loop with some test IF.

...


https://docs.google.com/document/d/1UQ1-PdU00kQnJCaLJDYHveWyEXLX_5MTv56fwvECb1w/edit?usp=sharing


I realize that if you could explain it well enough for someone
else to realize what your problem is, you should be able to see the
solution yourself.

It would be better if you could provide a short "elevator itch" on
what you're trying to do.

Cause "multidimensional arrays" can get hairy really fast.  I
mean, try building a sieve of erostothenses using arrays in integers
[0..maxint] in size.


+1

Unfortunately, (given that this is a Python list) I would suggest that 
(full-fat) SQL already offers solutions to such 'relationship issues'. 
(hah!) I'm not sufficiently familiar with SQL-Lite to know if/how well 
it manages multi-table "joins". So, back to Python...


Are you aware that it is possible to have one for-loop inside another? 
("nested")


In this case, use one for-loop to one of the tables, another loop for 
another table...


Start with (almost) empty loops which print only the key or identifier 
of 'that' particular table. You should then be able to assure yourself 
that every single combination of account and phone is covered.


Thereafter, complicate things by adding if-statements which cause 
appropriate action, or "pass"/do nothing.


Let us know how you get on...
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Nested Loop Code Help

2020-01-26 Thread DL Neil via Python-list

On 27/01/20 4:15 AM, ferzan saglam wrote:

Hello people, I have written the code below which works fine, but it has one 
small problem. Instead of printing one (x) on the first line, it prints two.
I have tried everything in my knowledge, but cannot fix the problem.
Thanks for any help in advance.
for x in range ( 0, 10):

   stars = 'x'  
   count = 0
while count < x: 
   stars = stars + 'x'  
   count = count + 1
   print (stars)


These loops are serial, ie one after the other, and not "nested" (one 
'inside' the other) - or the email messed-up the indentation.


However, why "nest" or have more than one loop, in any case?

>>> for i in range( 0, 10 ):
... print( "*"*i )
...

*
**
***

*
**
***

*
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


PEP-Dilbert

2020-01-26 Thread DL Neil via Python-list
Looks as if Dilbert is about to draft a PEP to change Python's 
world-view: https://dilbert.com/strip/2020-01-24


Curiously, "canard" whilst a French word for "duck", in English 
describes a rumor or false-story!

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: PEP-Dilbert

2020-01-26 Thread Peter J. Holzer
On 2020-01-27 13:02:03 +1300, DL Neil via Python-list wrote:
> Looks as if Dilbert is about to draft a PEP to change Python's world-view:
> https://dilbert.com/strip/2020-01-24
> 
> Curiously, "canard" whilst a French word for "duck", in English describes a
> rumor or false-story!

Interesting: In German, "Ente" (duck) also means a false story.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | [email protected] |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Nested Loop Code Help

2020-01-26 Thread Richard Damon

On 1/26/20 6:52 PM, DL Neil via Python-list wrote:

On 27/01/20 4:15 AM, ferzan saglam wrote:
Hello people, I have written the code below which works fine, but it 
has one small problem. Instead of printing one (x) on the first line, 
it prints two.

I have tried everything in my knowledge, but cannot fix the problem.
Thanks for any help in advance.
for x in range ( 0, 10):
   stars = 'x'
   count = 0
while count < x:
   stars = stars + 'x'
   count = count + 1
   print (stars)


These loops are serial, ie one after the other, and not "nested" (one 
'inside' the other) - or the email messed-up the indentation.


However, why "nest" or have more than one loop, in any case?

>>> for i in range( 0, 10 ):
... print( "*"*i )
...

*
**
***

*
**
***

*


First, your answer doesn't solve his problem, as his expected was lines 
of 1 to 10 stars, not 0 to 9.


Second, this smells a bit like homework, and if they haven't learned the 
results of string times integer, then using that operation wouldn't be 
in their tool kit, so having a loop to build that operator makes sense.


--
Richard Damon

--
https://mail.python.org/mailman/listinfo/python-list


Re: Nested Loop Code Help

2020-01-26 Thread DL Neil via Python-list

On 27/01/20 1:53 PM, Richard Damon wrote:

On 1/26/20 6:52 PM, DL Neil via Python-list wrote:

On 27/01/20 4:15 AM, ferzan saglam wrote:
Hello people, I have written the code below which works fine, but it 
has one small problem. Instead of printing one (x) on the first line, 
it prints two.

I have tried everything in my knowledge, but cannot fix the problem.
Thanks for any help in advance.
for x in range ( 0, 10):
   stars = 'x'
   count = 0
while count < x:
   stars = stars + 'x'
   count = count + 1
   print (stars)


These loops are serial, ie one after the other, and not "nested" (one 
'inside' the other) - or the email messed-up the indentation.


However, why "nest" or have more than one loop, in any case?

>>> for i in range( 0, 10 ):
... print( "*"*i )
...

*
**
***

*
**
***

*


First, your answer doesn't solve his problem, as his expected was lines 
of 1 to 10 stars, not 0 to 9.


Second, this smells a bit like homework, and if they haven't learned the 
results of string times integer, then using that operation wouldn't be 
in their tool kit, so having a loop to build that operator makes sense.



The reply to the first criticism is answered in the second - it only 
looks like the answer.


Notice also, that the character used, whilst a "star", is not what the 
OP wanted either.


Also, please recall that the OP has already accepted one answer (whether 
the 'right' one, or not, is another matter). If it was 'homework', what 
are the chances that (s)he will go back and 'change everything' after 
saying "done"? Would you? Would I?


A while back we had a rash of folk asking beginner questions. Not one to 
whom I posed the 'is this homework?' question, responded. Also, there is 
the Python Tutor list...


That said, there is no telling in which order people learn particular 
aspects of a topic [Python in this case]. A quick check of the reference 
I use, shows a listing of string functions (and other objects) before 
reaching looping constructs.


Learning that there are different ways of approaching the same 
problem/solution is valuable learning. How about taking a string of ten 
'stars' and printing progressively longer slices thereof, on successive 
lines? (that book has slices (of strings and lists) before loops too!) 
Did anyone suggest that it seemed a little odd to use both a for-loop 
and a while-loop? Why not both for-loops (there are finite starting and 
finishing points (and increments) after-all)?


BTW your earlier response extremely constructive. Have you seen Philip 
Guo's http://pythontutor.com/ ? It illustrates what we learned as 'paper 
computers', with all the advantages of dynamism! The site now makes it 
possible for learners to 'go' as far as they are able, and then to call 
for help; and for someone to peer-review, comment, and/or 
pair-program(me) right there with them!

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


RE: Python-list Digest, Vol 196, Issue 26

2020-01-26 Thread Francois van Lieshout
for x in range( 0,10 ):
stars = ""
count = 0

while count < x:
stars += "x"
count += 1
print( stars )

x
xx
xxx

x
xx
xxx

x

You've got already an "x" placed in your variable stars that's why.


-Oorspronkelijk bericht-
Van: Python-list  Namens 
[email protected]
Verzonden: zondag 26 januari 2020 18:00
Aan: [email protected]
Onderwerp: Python-list Digest, Vol 196, Issue 26

Send Python-list mailing list submissions to
[email protected]

To subscribe or unsubscribe via the World Wide Web, visit
https://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
[email protected]

You can reach the person managing the list at
[email protected]

When replying, please edit your Subject line so it is more specific than "Re: 
Contents of Python-list digest..."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python-list Digest, Vol 196, Issue 26

2020-01-26 Thread אורי
Please don't reply to digest.
אורי
[email protected]


On Mon, Jan 27, 2020 at 8:11 AM Francois van Lieshout <
[email protected]> wrote:

> for x in range( 0,10 ):
> stars = ""
> count = 0
>
> while count < x:
> stars += "x"
> count += 1
> print( stars )
>
> x
> xx
> xxx
> 
> x
> xx
> xxx
> 
> x
>
> You've got already an "x" placed in your variable stars that's why.
>
>
> -Oorspronkelijk bericht-
> Van: Python-list 
> Namens [email protected]
> Verzonden: zondag 26 januari 2020 18:00
> Aan: [email protected]
> Onderwerp: Python-list Digest, Vol 196, Issue 26
>
> Send Python-list mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> When replying, please edit your Subject line so it is more specific than
> "Re: Contents of Python-list digest..."
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list