Home > Enterprise >  how can i add text to a number inside a string
how can i add text to a number inside a string

Time:06-27

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

CodePudding user response:

Try replacing this with your append this:

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

CodePudding user response:

if i get u right, here's how u can do it:

big_nums = [1,2,3]

res = [f"{num} is too big"for num in big_nums]

print(res)
  • Related