From e511b2677129f32e6106ab1b2e6e1f06aa98485a Mon Sep 17 00:00:00 2001 From: chinya07 Date: Thu, 23 Aug 2018 14:48:24 +0530 Subject: [PATCH] updations in pattern programs --- Programs/P05_Pattern.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Programs/P05_Pattern.py b/Programs/P05_Pattern.py index b4da517..0289826 100644 --- a/Programs/P05_Pattern.py +++ b/Programs/P05_Pattern.py @@ -88,3 +88,24 @@ def pattern5(level): print() pattern5(userInput) print() + +''' +following is the another approach to solve pattern problems with reduced time complexity + +for + +* +** +*** +**** +***** +''' + +num = int(input('Enter number for pattern')) +pattern = '*' +string = pattern * num +x = 0 + +for i in string: + x = x + 1 + print(string[0:x])