wiki:ProgrammingAnswerPotatoExercise

Back to: Programming?


Potato Counting Exercise Solution

Solution

count=1
while (count<=7):
   if (count==4):
      print("more!")
   else: 
      print(count, end="") 
      for r in range(0,count):
         print(" potato,", end="")
      print("")
   count+=1
print("score!")

Output

1 potato,                                                                                                                                                                                                                                              
2 potato, 2 potato,                                                                                                                                                                                                                                    
3 potato, 3 potato, 3 potato,                                                                                                                                                                                                                          
more!                                                                                                                                                                                                                                                  
5 potato, 5 potato, 5 potato, 5 potato, 5 potato,                                                                                                                                                                                                      
6 potato, 6 potato, 6 potato, 6 potato, 6 potato, 6 potato,                                                                                                                                                                                            
7 potato, 7 potato, 7 potato, 7 potato, 7 potato, 7 potato, 7 potato,                                                                                                                                                                                  
score!  
Last modified 4 years ago Last modified on Sep 4, 2017, 9:50:41 PM