0

Can someone please rewrite the code and point out the mistakes, please?And please explain me how does it work.

https://code.sololearn.com/cThzWqUXxArJ/?ref=app

16th Feb 2021, 10:32 AM
Soumaya Islam Rimi
Soumaya Islam Rimi - avatar
4 odpowiedzi
+ 2
You might start by adding the parentheses to the split call on line 2 so that it calls the method instead of just referring to it. split() not split You will also alway eventually get an error since you are using an infinite loop with no break. I.E. an EOF error will always happen
16th Feb 2021, 10:40 AM
ChaoticDawg
ChaoticDawg - avatar
0
In the 2nd line it should be .split() instead of .split . Because split() is a method, not attribute. Also in the last while loop, it will raise an error after all inputs are taken . That is because it is an infinite loop. So adding a try except will help the code to remain alive . While True: try: get_input() except: print('game over') break break statement will help to get out of the infinite loop . Hope these helps https://code.sololearn.com/c7vhpnCPtudL/?ref=app
16th Feb 2021, 10:58 AM
Mir Abir Hossain
Mir Abir Hossain - avatar
0
Thank you all..
16th Feb 2021, 11:59 AM
Soumaya Islam Rimi
Soumaya Islam Rimi - avatar
0
'''If you want to say more than just one word you can change the code from if len(command)>=2: noun_word=command[1] print(verb(noun_word)) And make it like this''' if len(command)>=2: noun_word = "" for restofwords in command[1::]: noun_word += " " + restofwords print(verb(noun_word)) ''' This way the code takes all the words in the list after the verb and outputs them together '''
16th Feb 2021, 12:51 PM
Ezequiel Lopez Saaied
Ezequiel Lopez Saaied - avatar