Jan-23-2018, 12:13 AM
Hi everyone,
First time poster here. Been studying python about 2 weeks now.
I am trying to loop through a list to check if a certain value is in it. The value will be random but will always contain a * at the front.
Here is the code I am using to loop through:
And pycharm tells me there is a : expected in the if statement even though it already has one.
I feel like in other languages I would use a contains function but this does not exist in python.
I have spent around 3-4 hours searching the web and I have come back with nothing.
Help appreciated.
First time poster here. Been studying python about 2 weeks now.
I am trying to loop through a list to check if a certain value is in it. The value will be random but will always contain a * at the front.
Here is the code I am using to loop through:
for x in stringsplit: if x = \*: print (x)I am getting this error from python: SyntaxError: invalid syntax
And pycharm tells me there is a : expected in the if statement even though it already has one.
I feel like in other languages I would use a contains function but this does not exist in python.
I have spent around 3-4 hours searching the web and I have come back with nothing.
Help appreciated.