Introduction
A list can be used to store well, a list of entries such as strings like “This”. these list can be used to store multiple strings rather than overwriting it.
variable = "Somevariable"
listvariable = ["somevariable1", "somevariable2"]
What Is A While True Statement In Basic Terms?
A “While True” statement is when the code is told to run forever, in some cases it’s bad for your computer as it takes up memory and processing power.
While True:
print("My Name Is")
something>username> whiletrue.py
My Name Is
My Name Is
My Name Is
My Name Is
My Name Is
My Name Is
My Name Is
In this example we are using a “While True” statement to print “My Name Is” forever, Also notice that there’s an indent underneath While True before print? That is there to tell the computer While True run these commands nested underneath for infinity.
What is If Or Else Statements In Basic terms?
An if else statement is that if a condition = Y run the script underneath it, but else if theĀ condition = N run the script underneath it and if it’s anything else it’ll print “That’s Not An Option!”.
The Full Code (Very Small)
variable = "somevariable"
listvariable = []
while True:
yesorno=input("Would You Like To Add An Entry? Y/N ")
if yesorno == 'Y':
listvariable.insert(-1, input("Name "))
print(listvariable)
elif yesorno == 'N':
pass
else:
print("Thats Not An Option!")