Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

This is the code I am using:

def pomo_code_apply():

    if success_name==1:

        print(" "*79,'-$3.00')

    if success_name==3:

        print(" "*78, '-$10.00')

    if success_name==2:

        print(" "*79, '-$7.00')

    else:

        print()

and this is to call function

        if success==1:

            print('   Promotion Code',pomo_code_apply())

But in the output, I am getting this(for this eg let success_name==1)

                                                                               -$3.00

   Promotion Code None

however, I want to:

Promotion Code                                                             -$3.00

I don't understand why there is a new line for the -3 and why pomo_code_apply() returns both none and -3

1 Answer

0 votes
by (36.8k points)

This is the code:

success_name = 1

def pomo_code_apply(success_name):

    if success_name==1:

        a =  " "*79 + '-$3.00'

        return a

    if success_name==3:

        a = " "*78 + '-$10.00'

        return a

    if success_name==2:

        a = " "*79 + '-$7.00'

        return a

    else:

        return

print('Promotion Code {}'.format(pomo_code_apply(success_name)))

You will get the output as:

Promotion Code                           -$3.00

 Do check out Data Science with Python course which helps you understand from scratch

Browse Categories

...