2 Replies - 311 Views - Last Post: 10 December 2012 - 03:48 PM Rate Topic: -----

#1 Brilliantwarrior  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 05-December 12

Inserting input stored in a variable into a while loop.

Posted 10 December 2012 - 03:06 PM

I'd just like to know how you would insert input that is stored in a variable into a while loop. Also I'd like to know what Boolean expression is best to use.
Is This A Good Question/Topic? 0
  • +

Replies To: Inserting input stored in a variable into a while loop.

#2 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,693
  • Joined: 13-March 10

Re: Inserting input stored in a variable into a while loop.

Posted 10 December 2012 - 03:21 PM

I dont understand what you are trying to accomplish.
My best guess is:
value = "string"
while(True):
   print(value)


Was This Post Helpful? 1
  • +
  • -

#3 Nallo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 163
  • View blog
  • Posts: 255
  • Joined: 19-July 09

Re: Inserting input stored in a variable into a while loop.

Posted 10 December 2012 - 03:48 PM

The question is a bit difficult to understand. I guess you still try to solve your old problem of reading a non determined number of inputs until "END" appears as input.

I hate to comply to "give me the codes" kind of questions. But for something that basic I cannot help it. Any explanation would be confusing. So once in a while:

keep_asking_for_input = True
input_list = []
while keep_asking_for_input == True:
    s = input("blahblah")
    if s == "END": #or whatever is the codeword for ending input
        keep_asking_for_input = False
    else:
        input_list.append(s)
#now do something with the input_list data


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1