Jan-30-2017, 10:01 PM
(This post was last modified: Jan-30-2017, 10:10 PM by BurnedChipotle.)
(Jan-26-2017, 09:45 PM)micseydel Wrote:I understand what you mean, I can assure that I have written this coding in my lessons however now that I have moved on to the write up section I struggle with explaining it as I've only just started learning Python this year. I just need to know how the Position variable, which I now know is an Integer variable works in my code and also how the words=sentence.split(" ") variable works.(Jan-26-2017, 09:04 PM)BurnedChipotle Wrote: have to do a write up explaining what my the variables are in my code and what they do, can somebody explain to me why am I using these certain variables or give me advice on what to write?Please don't take this as an accusation, but when someone says something like this my first thought is, "they found this code online and need someone to explain it to them." At the very least, you should be asking more specific questions or making an attempt and asking us to point out problems with that attempt. Generally, we aren't going to do anyone's homework for them, even if they've already succeeded with part of that homework.
Also, metulburr is right that you should be using code tags but in any case your image link looks broken to me.
My coding is below
sentence=input ("type in the list you wish to be counted ").lower() keyword=input ("enter the word to be searched ").lower() words=sentence.split(" ") position=1 for word in words: if word==keyword: print ("found at {0}".format (position)) position=position+1 if not keyword in words: print ("Error: word was not found in list")