line.startswith('Hello')
How can I check and see if it does not contain 'hello'?
a c++ example would be
if (line != "Hello"){
cout<<" wrong ";
}
whats the equivalent in python?
This post has been edited by dstudentx: 02 May 2010 - 12:54 PM




Posted 02 May 2010 - 12:38 PM
line.startswith('Hello')
This post has been edited by dstudentx: 02 May 2010 - 12:54 PM
Posted 02 May 2010 - 06:45 PM
# Returns 7 because character index 7 is where 'hello' starts
'Hi and hello to you'.find('hello')
# Returns -1 because 'hello' is not found
'Hi and howdy to you all'.find('hello')
# Throws a ValueError because 'hello' is not found
'Hi and howdy to you all'.index('hello')
Posted 02 May 2010 - 08:27 PM
if line.find('Hello /'):
found = True
print 'Booyah'
Posted 03 May 2010 - 12:05 AM
dstudentx said:
>>> s = "abc Hello def" >>> 'Hello' in s True >>> 'abc' in s True >>> 'ghi' in s False >>> 'ghi' not in s True >>>
Posted 03 May 2010 - 12:07 AM
This post has been edited by c.user: 03 May 2010 - 12:08 AM
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
