Jun-29-2020, 04:40 PM
Well, the problem with the second loop is that it will only work for the character immediately after the "@". There are two better and easier ways to do this.
string = "[email protected]" split = string.find("@") print("User:", string[:split]) print("Host:", string[split:])
string = "[email protected]" split = string.split("@") print("User:", split[0]) print("Host:", split[1])