what is wrong with the code it prints nothing? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is wrong with the code it prints nothing?

https://code.sololearn.com/ckA7Kng6vd78/?ref=app i tried to write some code that checks the last letter of the word is equal to the first of the successor in every word in a sentence and to print true or false if the condition holds or not respectively. but after i entered a sentence nothing got printed

4th Oct 2023, 9:33 AM
Anesensi Jonas
Anesensi Jonas - avatar
11 Answers
+ 3
Anesensi Jonas , i have put my comments in a python file, since the number of characters is limited in the posts. > it's spotting out the issues that causes the code problems < https://code.sololearn.com/cdU8ODNclfya/?ref=app
4th Oct 2023, 9:02 PM
Lothar
Lothar - avatar
+ 3
Masaku Mwangangi , this is the question & answer forum for coding related questions. >>> all other things should be posted in the feed that is located in the community section.
5th Oct 2023, 11:07 AM
Lothar
Lothar - avatar
+ 3
Anesensi Jonas , you can find a code in the attached file that is based on your try, but with some fixes and modifications as described in the last answer. the code is very basic, so it should be readable by you. the state variable holds a bool value that indicates the current state. https://code.sololearn.com/c31vyXj7KGjw/?ref=app
5th Oct 2023, 7:44 PM
Lothar
Lothar - avatar
+ 1
I can not find any problem in your code. It runs fine in the playground and print 'true' and 'false' depends on your input. However you can simplify you code a bit. After you received the sentence and assigned it to variable sentence, you can turn it into a list without the map() method. sentence = sentence.split() # It split the string with 'space' separator If you did not provide the separator for the split() method, the 'space' is the default separator. After above statement ran, variable sentence become a list.
4th Oct 2023, 12:41 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
Hi 👋
5th Oct 2023, 9:20 AM
Masaku Mwangangi
Masaku Mwangangi - avatar
+ 1
Lothar what is a state variable? i don't know anything about it, or maybe i am not aware of the name also, in the case of range which the code will iterate through , won't removing that -1 cause an error, because of the behavior of indexing they start at zero and this may lead to indexing thing that is not actually there hence will raise an error(index out of range)
5th Oct 2023, 12:03 PM
Anesensi Jonas
Anesensi Jonas - avatar
0
why then if i run in pydroid 3 it just ask input and when i provide it it says that program finished executing , no answer either true or false is outputed?. i forgot to taste here but thanks for telling me though can you at least tell if you have a clue?
4th Oct 2023, 2:10 PM
Anesensi Jonas
Anesensi Jonas - avatar
0
I do my coding on PC and had no experience on pydroid 3 before. Now I just installed pydroid 3 on my android tablet, config it to work like on console, type in your code to the letters, and it runs perfectly. Maybe there is some setting preventing it to display result? Like it was configured to GUI projects?
4th Oct 2023, 2:33 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
did you try to run that code on pydoid too? i don't know how to configure it, but all codes works just perfectly fine, but somes codes which uses if statement have this kind of anomaly when i run in pydroid but though rarely
4th Oct 2023, 4:32 PM
Anesensi Jonas
Anesensi Jonas - avatar
0
Anesensi Jonas, yes, I ran your code in pydroid 3 and it worked for me. You may try to uninstall and re-install it to see if the problem resolved. If it doesn't, you may need to contact the developer for help. If it is a software specific problem, there is not much we can do here.
5th Oct 2023, 3:10 AM
Wong Hei Ming
Wong Hei Ming - avatar
0
ok thanks a lot🤗
6th Oct 2023, 3:40 AM
Anesensi Jonas
Anesensi Jonas - avatar