how can i add text to a number inside a string

Issue

def sorter (*arguments):

big_numbers = []
small_numbers = []

for n in argument:
    if n**5 >100000:
        big_numbers.append (n**5) 
    else:
        small_numbers.append(n**5)



print (f 'big numbers: {big_numbers} \n small numbers: {small_numbers}')

sorter(8,2,66,45,3,7,9)

i want to add to each number the function prints to add text such as :’ is too big’ so the output will be something like :
[10000 is too big, 400000 is too big]
thank you

Solution

Try replacing this with your append this:

big_numbers.append (f'{n**5} is too big') 

Answered By – Mehrdad Pedramfar

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published