My code is not returning anything! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

My code is not returning anything!

The President's phone is broken He is not very happy. The only letters still working are uppercase E, F, I, R, U, Y. An angry tweet is sent to the department responsible for presidential phone maintenance. Kata Task Decipher the tweet by looking for words with known meanings. FIRE = "You are fired!" FURY = "I am furious." If no known words are found, or unexpected letters are encountered, then it must be a "Fake tweet." Notes The tweet reads left-to-right. Any letters not spelling words FIRE or FURY are just ignored If multiple of the same words are found in a row then plural rules apply - FIRE x 1 = "You are fired!" FIRE x 2 = "You and you are fired!" FIRE x 3 = "You and you and you are fired!" etc... FURY x 1 = "I am furious." FURY x 2 = "I am really furious." FURY x 3 = "I am really really furious." etc... Examples ex1. FURYYYFIREYYFIRE = "I am furious. You and you are fired!" ex2. FIREYYFURYYFURYYFURRYFIRE = "You are fired! I am really furious. You are fired!" ex3. FYRYFIRUFIRUFURE = "Fake tweet." My code: def fire_and_fury(tweet): fur_sent = 'I am furious. ' fir_sent = 'You and ' fir_c = tweet.count('FIRE') fur_c = tweet.count('FURY') if fur_c == 1 and fir_c == 1: return fur_sent + fir_sent if fur_c > 1: fur_sent = fur_sent[:4] + (' really ' * fur_c) + 'furious.' if fir_c > 1: fir_sent += 'you '* (fir_c-1) + 'are fired!' if tweet[0] == 'FIRE' and tweet[-1] == 'FIRE': return fir_sent + fur_sent + fir_sent elif tweet[0] == 'FIRE' and tweet[-1] == 'FURY': return fir_sent + fir_sent + fur_sent elif tweet[0] == 'FURY' and tweet[-1] == 'FURY': return fur_sent + fir_sent + fur_sent elif tweet[0] == 'FURY' and tweet[-1] == 'FIRE': return fur_sent + fur_sent + fir_sent else: return 'Fake tweet.' My code doesn't return the sentence in the if statements. Plz help

11th Nov 2021, 12:36 AM
Ailana
Ailana - avatar
1 Answer
+ 1
Most likely, your execution stops on some of the conditions. Review them.
11th Nov 2021, 4:01 AM
Viktor Karpov
Viktor Karpov - avatar