'Make a variable from what's in a text file

So I want to make a variable from the contents of a text file.

E.g The text file contains the sentence "Ask not what your country can do for you ask what you can do for your country"

Now I want the variable to be a string which contains the sentence in text file: Sentence = ("Ask not what your country can do for you ask what you can do for your country")

But import the string value from the text file, if that makes any sense?



Solution 1:[1]

The file contains.

rahul@HP-EliteBook ~/Projects/Stackoverflow $ cat abc.txt 
hai am here

Here is the python code.It's very simple logic.

fo = open("abc.txt", "r+")
a = fo.read()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rahul K P