--Originally published at Fundamentos de Programación
Ok so this is my work of today.
i wanted to do something more tricky. In this code I intendendt to make a program to store the names of people signed up for a course.
First you need to create an empty list (a=[]), and a variable to count the loops of while (cupo=0)
Then the magic starts. While creates a loop until the condition is achieved (cupo<=4), I wanted the course to be of 5 people so why did I put <=4? Because there is a loop while with the value 0 so counting that one when you reach 4 there have been already 5 loops.
Every time the loop happens the program will ask for a name (input) and store it in the variable named student and add it to the list.
When there are already 5 names on the list the program prints a ‘list’ of the names that are signed up for the course using ‘for’ to print each name on a diferent line.
And this is what it looks like when you run it:
And at the end it looks like this:
So I hope you learn something from this #python #TC101
source:
https://docs.python.org/3/tutorial/datastructures.html
http://www.python-course.eu/python3_loops.php