[Solved] Open txt file in python


Notice that the names are separated by a colon(:) so add : in split() to split them and store them in multiple variables:

    with open("filename.txt") as f:
        for line in f :
            word1,word2,word3 = line.split(":")

    print(word1)
    print(word2)
    print(word3)

0

solved Open txt file in python