Reputation: 73
my_string = "wolfofwalstreet(2012)is a movie"
Need to run python script to check if it contain the character: bracket
"("
Upvotes: 5
Views: 17040
Reputation: 2952
This code will give you the index of the character been found.
my_string = "wolfofwalstreet(2012)is a movie"
result = my_string.find('(')
print("Found", result)
If the character is not found, you receive an '-1'.
As described by the answers below, you can of course but it in an IF-statement.
Upvotes: 4
Reputation: 139
hi you can check by this way:
my_string = "wolfofwalstreet(2012)is a movie"
if '(' in my_string:
print('yes')
else:
print('no')
Upvotes: 10
Reputation: 3225
my_string = "wolfofwalstreet(2012)is a movie"
if '(' in my_string:
print('yes, "(" is in my_string')
Upvotes: 2