The program outputs is incorrect. Try to use only one print statement instead of return

Viewed 17

I run the below code and have this output('c, e, i and l') but I keep getting this feedback from a robot pytest error that task 10 should print (and not return) a string. Please just use one print statement. Example: task10('I like big cups!', 'and I cannot lie!') should print('c, e, i and l')

def task10(str1,str2):
    str1=str1.lower()
    str2=str2.lower()

    badchars = ['$','@','%',';',':','!',"*"," ",'1',"2","3","4","5","6","7","8","9","0",'^','&','#','~','?','[]','{',']',"+",'=','-','_','-',",",'"',"'",'`',"|","\\",'(',')']

    for i in badchars:
        str1=str1.replace(i,"")
        str2=str2.replace(i,"")

    common = list(set([c for c in str1 if c in str2]))
    i=len(common)
    if i==0:
        common=['no common letters']
    common.sort()
    if i>1:
        common.insert(-1,"and")

    common= ','.join(common)
    common = common.replace(',and,', ' and ')
    print(f'{common}')

task10("I like big cups!", "and I cannot lie!")
0 Answers
Related