Python typeError


#1
length = 1000
def general(text, style='-', extra=0):
    sides = ''.join([style] *  (((length - len(text)) - 4 ) / 2))
    titel =  sides + '  ' + text + '  ' + sides
    middle = sides + ''.join([' '] * (len(text) + 4)) + sides
    print('')
    for _ in range(extra):
        print(''.join([style] * len(middle)))
    for _ in range(extra):
        print(middle)
    print(titel)
    for _ in range(extra):
        print(middle)
    for _ in range(extra):
        print(''.join([style] * len(middle)))
    print('')

Output : TypeError: can’t multiply sequence by non-int of type 'float’
I use Python 3.6


#2

here:

sides = ''.join([style] *  (((length - len(text)) - 4 ) / 2))

length is undefined. If you want us to help you, please provide us with a copy where we can actually replicate the problem so we know the value of the different variables. We are just human, not magicians.


#3

you’re right. I previosly define length as follow : length = 1000


#4

But i still don’t know what the function call arguments are, i don’t know what the function is suppose to do and so on.

like i said:

its frustrating when you try to help someone, and you ask for the information needed, and you only get a small portion of what you requested


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.