python - What should I do to fix my code? -



python - What should I do to fix my code? -

here code

def print_chars(num,char): print(char*num) homecoming def sum_arithmetic_seq(num): total= num in range(1,num): total += homecoming total def factorial(num): total= num in range(1,num): total *= homecoming total #final num in range(1,7): print(num) print('sum :',print_chars(sum_arithmetic_seq(num), '*')) print('factorial:',end = ' ') print_chars(factorial(num),'#')

here output

1 * sum : none factorial: # 2 *** sum : none factorial: ## 3 ****** sum : none factorial: ###### 4 ********** sum : none factorial: ######################## 5 *************** sum : none factorial: ######################################################################################################################## 6 ********************* sum : none factorial: ################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################

i need stars sum: should do?

rewrite print_chars returns value instead of printing it.

def print_chars(num,char): homecoming char*num

now print('sum :',print_chars(sum_arithmetic_seq(num), '*')) work desired. although you'll have alter lastly line print_chars(factorial(num),'#') print print_chars(factorial(num),'#').

(and additional style points, rename print_chars else, because doesn't print characters anymore. repeated_chars? it's you.)

python python-3.x

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -