Nested Loop Code Help

ferzan saglam ferzans97 at gmail.com
Sun Jan 26 10:15:28 EST 2020


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
xx                                                xxx
xxx                                               xxxx
xxxx                                              xxxxx
xxxxx                                             xxxxxx
xxxxxx                                            xxxxxxx
xxxxxxx                                           xxxxxxxx
xxxxxxxx                                          xxxxxxxxx
xxxxxxxxx                                         xxxxxxxxxx
xxxxxxxxxx


More information about the Python-list mailing list