I\'m stuck in this problem in python 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file will hold. * Make sure your program starts and is driven from a main() function. * Your program should have at least one additional function that you write and use. Well, this is my code, but when I run it in IDLE it comes back as a syntax error----expected an indented block def main(): import random afile = open(\"Random.txt\", \"w\" ) try: for i in range(int(input(\'How many random numbers?: \'))): line = str(random.randint(1, 100)) afile.write(line) print(line) except ValueError: # error handling afile.close() print(\"\ Reading the file now.\" ) afile = open(\"Random.txt\", \"r\") print(afile.read()) afile.close() main() Solution The problem because of input returns a string in Python, so type cast line into string is very necessary. Here is the modified code:- def main() import random afile= open(“Random.txtâ€, â€wâ€) For i in range(input(‘How many random number?: ‘)): line = str(random.randint(1, 500)) afile.write(line+str(“\ â€)) print(line) afile.close() print(“\ Reading the file now.â€) afile = open(“Random.txtâ€, â€râ€) print(afile.read()) afile.close() main() And if u want to use exception handling follow these down code:- def main() import random afile= open(“Random.txtâ€, â€wâ€) try For i in range(input(‘How many random number?: ‘)): line = str(random.randint(1, 500)) afile.write(line+str(“\ â€)) print(line) except ValueError: afile.close() print(“\ Reading the file now.â€) afile = open(“Random.txtâ€, â€râ€) print(afile.read()) afile.close() main() .