Python Forum

Full Version: While loop variable defining
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys I want to create something like a database here is my code
i=0
#f=open('t.txt', 'w')
#f.write('Hello')
while True:
name=input('Name ')
if name=='stop':
break
age=input('age ')
car=input('car ')
salary=input('Salary ')
adress=input('Address ')
personality=input('persnality ')
l=[i, [name, age, car, salary, adress, personality]]
#f.write(l)
print(l)
i=i+1
Hello, please edit your post so that Python code is included in Python code tags. And when you copy code, use shift+ctrl+v so that indentation is preserved.
You also need to ask a question. What are you trying to do, what isn't working right, what is it doing instead or what error messages are you getting?
 i=0
#f=open('t.txt', 'w')
#f.write('Hello')
while True:
     name=input('Name ')
     if name=='stop':
         break
     age=input('age ')
     car=input('car ')
     salary=input('Salary ')
     adress=input('Address ')
     personality=input('persnality ')
     l=[i, [name, age, car, salary, adress, personality]]
     #f.write(l)
     print(l)
     i=i+1
      

Im trying to use while loop to define some variables and then i need some sort of access to them maube with the .index or something elss
(Jan-04-2018, 04:14 PM)j.crater Wrote: [ -> ]And when you copy code, use shift+ctrl+v so that indentation is preserved.
Just some info there is no longer need to use shift+ctrl+v after the changes we done to editor.
Indentation will now always be preserved if user have indentation from start.
You can just look at his first post with edit post and see that indentation is there,
but missing code tag so then do not indentation show in post.