I cant figure out the read part of the Python program. Please assist
Question: Write:

    
    
    def main():
    
        import random
    
        #Open a file named numbers.txt.
        myfile = open('numbers.txt', 'w')
    
        file_size= random.randint(4,7)
    
    
        #Produce the numbers
        for i in range(file_size):
            k = random.randrange(5,19,2)
    
    
    
            #Write as many random intergers as the user request in the range of 5-19 on one line
            #to the file.
            myfile.write(str(num) + ' ')
    
        #Close the file.
        myfile.close()
        print('File Saved')
    
    #Call the main function
    main()
    

Read: How do i get the read coding to display the random numbers and also
provide the sum?

    
    
    def main():
    
    
        import random
    
      #Open a file named numbers.txt.
        myfile = open('numbers.txt', 'r')
    
        #Read/process the file's contents.
        file_contents = myfile.read()
        numbers = file_contents.split(" ")
        odd = 0
        num = int(file_contents)
        for file_contents in numbers:
         odd += num
    
        #Close the file.
        myfile.close()
    
        #Print out integer totals
    
        print('The total of the odd intergers is: ', odd)
    


Answer: You want to write every number into the file, therefore, you need to include
it within the for loop:

    
    
    #Produce the numbers
    for count in range(file_size):
        num = random.randrange(5,19,2)
        myfile.write(str(num) + ' ')
    

When processing the numbers in, you're on the right track, but you've got it
out of order:

    
    
    numbers_as_strings = file_contents.split(" ")[:-1]
    odd = 0
    

numbers is a list of strings representing each number, we want to iterate
through them and do something for each of them. You may wonder why I added
`[:-1]`? Because we made a string like `"1 2 3 4 5 "` See the last space? when
you `split()` that, you'll get `"1","2","3","4","5",""`, and we don't want the
last empty string `""`.

    
    
    for number_as_string in numbers_as_strings:
        odd += int(number_as_string)
    

finally, to print the list of numbers there is a nice way of doing that built
into python, `join()`. `' '.join()` says put all these together, and put that
space (`' '`) between them.

    
    
    print(' '.join(numbers_as_strings))
    

