Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: stuck with python, please advise
12-30-2011, 01:10 AM #1
- Join Date
- Dec 2011
- Thanked 0 Times in 0 Posts
stuck with python, please advise
so im trying to make it so that pressing enter without inputting any value, will break the loop, however, an empty string can be used because of
for i in range(len(x_str_array)):bit.
x[i] = int(x_str_array[i])
'Exercise 7.3' # modified program from exercise 7.2 a=1 z="" while x !=z: x_str = raw_input('Enter Start,Stop,Increment: ') if x==z: break else: x_str_array = x_str.split(',') # splits the string where a comma pops up x = range(len(x_str_array)) # Preallocation step- makes x= the same length as x_str_array for i in range(len(x_str_array)): x[i] = int(x_str_array[i]) a=x b=x c=x for number in range(a,b,c): print "number:", number, " square:", number**2, " cube:", number**3
p.s yes i am a complete novie, haha
i thought maybe using an empty tuple or list or something, but that wouldn't work either.
01-01-2012, 01:19 PM #2so that pressing enter without inputting any value, will break the loopCode:
while True: # Get some user input. x_str = raw_input("Someting: ") # If the user simply hits enter or supplies a string full of spaces, break. if not x_str or x_string.isspace(): break # More stuff here.I am a Man of Truth. I am a Free Human Person. I am a Peacemaker.
** Independent Multimedia Artist in Pasig **