Hi, I am new to python but learned somewhat about lists, tuples, dictionaries, db and gui (just introductory stuffs), and am trying to write a program that will alllow users to input some key words to search in a report. if key words are present in the report then the program should highlight them either yellow or red or any color highlight over the key words.

how can i code it?

Thanks

Member Avatar for masterofpuppets

hi,
here's a small example illustrating the find function:

s = """This is an example
string searching method."""

word = "searching"
print s.find( word )
# -> 26
# and some documentation for the function:

#Help on built-in function find:

#find(...)
#    S.find(sub [,start [,end]]) -> int
    
#    Return the lowest index in S where substring sub is found,
#    such that sub is contained within s[start:end].  Optional
#    arguments start and end are interpreted as in slice notation.
    
#    Return -1 on failure.

you should check vegaseat's example on highlighting words in text, I think it is in here:

http://www.daniweb.com/forums/thread191210-8.html

hope this gives you some ideas :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.