Q:

max_width = int(input()) ValueError: invalid literal for int() with base 10: ''

i am trying to write a program which takes strings and width as input and gives an input: 
ABCDEFGHIJKLIMNOQRSTUVWXYZ
4
and gives an output as(in newline):
ABCD \n
EFGH \n
IJKL \n
IMNO \n
QRST \n
UVWX \n
YZ
I wrote this code:
def wrap(string, max_width):
    while 0 < len(string) < 1000 and 0 < max_width < len(string):
        print (textwrap.fill(string,max_width))

while True:
    try:
        string = input()
        max_width = int(input())
    except EOFError:
        print("EOFError")
        break

What can i do to solve this problem, I am still new to programming. The error message which i got was:
Original exception was:
Traceback (most recent call last):
  File "try2.py", line 8, in <module>
    max_width = int(input())
ValueError: invalid literal for int() with base 10: ''

A:

Each input() "consumes" the whole line. You need to split it in 2 or input it as two lines. Your error comes if you input all in 1 line and hit return twice, the int(input()) becomes an empty string literal to convert which raises a ValueError - not a EOFerror (https://docs.python.org/3/library/exceptions.html)
I added handling for both of them, wrong parsing outputs a "helptext", empty line quits it 
Splitting version: 'ABCDEFGHIJKLIMNOQRSTUVWXYZ 4'
def wrap(string, max_width):
    print('\n'.join( [ string[i:i+max_width] for i in range(0,len(string),max_width) ]) )

while True:
    try:
        s = input()               #   ABCDEFGHIJKLIMNOQRSTUVWXYZ 4 + return
        if not s:
            print("Empty input quits program.")
            break
        spl = s.split()    

        string, max_width = spl[0], int(spl[1])
    except ValueError: 
        print("ValueError: place text and spacing into 1 line, separated by space")
        continue
    except IndexError:
        print("ValueError: place text and spacing into 1 line, separated by space")
        continue
    wrap(string,max_width)

should work. The list expression creates slices from your input starting at [0:0+max_width] and increases it by max_width concattenating them with '\n' for printout.
Two inputs version: 'ABCDEFGHIJKLIMNOQRSTUVWXYZ' and '4' in different lines:
def wrap(string, max_width):
    print('\n'.join( [ string[i:i+max_width] for i in range(0,len(string),max_width) ]) )

while True:
    try:
        string = input()             #   ABCDEFGHIJKLIMNOQRSTUVWXYZ + return
        if not string:
            print("Empty input quits program.")
            break
        max_width = int(input())     #   4 + return
    except ValueError:
        print("ValueError: place text into 1 line, number into next line")
        continue
    wrap(string,max_width)

