Search code examples
pythonraw-input

print after a certain word in python


In Python, I would like to read the input and then only print after a certain point. I would like for it to work like this

    humaninput = raw_input("Please enter:")
    breakdown = humaninput.split()
    say = "say"
    if say in breakdown:
        print (all words after say)

I have everything except for the last part


Solution

  • Since you converted all the entries in to a list you can find the first instance of "say", then make a new list with everything after it.

    humaninput = "This is me typing a whole bunch of say things with words after it"
    breakdown = humaninput.split()
    say = "say"
    if say in breakdown:
        split = breakdown.index(say)
        after = breakdown[split+1:]
        print(after)