L
L
lom1k2021-08-16 22:16:00
Python
lom1k, 2021-08-16 22:16:00

How to use endswith in a condition?

Good evening everyone! I'm a beginner, so I need help... It is necessary that when entering an email, the program checks for the presence of a certain word (for example, @mail.ru) and skips such mail, and if you enter another one, it gives an error, finds the endswith method, but I can’t figure out how to In my case it is correct to use it.

c = input ("Введите свой e-mail: ")
if c.endswith("mail.ru")
   print("E-mail: " +str(c))
else:
    print("Ошибка")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-08-16
@lom1k

The colon is omitted. A beginner should read the tutorial to learn the basic syntax at least.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question