def take_integer_from_user(message): inp = raw_input(message) while True: try: int(inp) break except ValueError: inp = raw_input('You must specify a number: ') return int(inp) fig_swiss = plt.figure() dg = DataGenerator() inp = take_integer_from_user('Press 1 for photos, 2 for Swiss Roll: ') if inp == 1 : a = dg.generateFacesPoints("C:\\Users\\Elrassam\\Desktop\\Faces\\s") numOfPoints = 400 elif inp == 2: numOfPoints = take_integer_from_user('Enter the number of points: ') a=np.zeros((numOfPoints,3)) ins = open( "1500.txt", "r" ) i = 0 for line in ins: j = 0 nums = line.split(' ') for nu in nums: a[i,j] = nu j += 1 i += 1 # a = dg.generateSwissRoll(numOfPoints, 3) # np.savetxt('1500.txt', a)