python read in a txt file and assign strings to combined variable (concatenation)
<p>I have a text file (Grades) where I'm given last name, first name, and grades. I need to read them in, assign them to variables, and write them to a different text file (Graded). I'm a beginner and this is my first hw assignment. There are errors I know, but the biggest thing I want to know is how to read in and then write to the file, as well as how to combine the 3 variables into one. </p>

<pre><code>class Student:
    def __init__(self, str_fname, str_lname, str_grade):
        """Initialization method"""
        self.str_fname = str_fname
        self.str_lname = str_lname
       self.str_grade = str_grade

    @property
    def str_fname(self):
        return self.str_fname

    @str_fname.setter
    def str_fname(self, str_fname):
    """Setter for first name attribute"""
        if not isinstance(str_fname, str):
            #This is not a string, raise an error
            raise TypeError
        self.fname = str_fname

    @property
    def str_lname(self):
        """Return the name"""
        return self.str_lname

    @str_lname.setter
    def str_fname(self, str_lname):
        """Setter for last name attribute"""
        if not isinstance(str_lname, str):
            # This is not a string, raise an error
            raise TypeError
        self.str_lname = str_lname

    @property
    def str_grade(self):
        """Return the name"""
        return self.str_grade

    @str_grade.setter
    def str_grade(self, str_grade):
        """Setter for grade attribute"""
        if not isinstance(str_grade, str):
            # This is not a string, raise an error
            raise TypeError
        self.str_grade = str_grade


Student = str_lname+str_fname+str_fname
f = open('Grades.txt', 'r')
g = open('Graded.text', 'w')
f.read()
g.write()
</code></pre>

<p>Have you read through the Python tutorial?
<a href="https://docs.python.org/3.6/tutorial/inputoutput.html#reading-and-writing-files" rel="nofollow">https://docs.python.org/3.6/tutorial/inputoutput.html#reading-and-writing-files</a></p>

python file read-write