"it must contain an “@” symbol
which is NEITHER the first character nor the last character in the string."
So I have this assignment in my class and I can't for the life of me figure out how to make the boolean false for having it at the front or end of the email. This is what I have so far.
for i in myString:
if i == "@":
s as your string, you can do:
not (s.endswith('@') or s.startswith('@')) and s.count('@')==1
def valid(s): return not (s.endswith('@') or s.startswith('@')) and s.count('@')==1 cases=('@abc','abc@','abc@def', 'abc@@def') for case in cases: print(case, valid(case))
@abc False abc@ False abc@def True abc@@def False