Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How I read a word after the @ symbol

I’m having a problem. I need to create the @everyone_or_person feature. A bit like discord. But I’ll have to be able to read the word after the @ and stop reading when there is a ("SPACE"/"_") and check for that word in the list. I’ve appended a simple version as an example. I knew it would not work but I couldn’t think of anything else.

input = input("input: ")
value = input.find("@")

output = input.partition("@")[0]
print(str(output))

I’ve tried to look up how to do it but to no avail.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

simply use split:

test = "Some input with @your_desired_value in it"
result = test.split("@")[1].split(" ")[0]
print(result)

this splits your text at the @, takes the entire string after the @, splits again at the first space, and takes the string before that.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading