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]

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

>Solution :

simply use split:

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

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

Leave a Reply Cancel reply