From 6272b47a037229644b48b5c0971cdd87247c8c24 Mon Sep 17 00:00:00 2001 From: Vicky-Raghuwanshi07 <74697810+Vicky-Raghuwanshi07@users.noreply.github.com> Date: Tue, 5 Oct 2021 18:42:18 +0530 Subject: [PATCH] for_loop.py This one will show you how for loop works on a list/set/ dict --- python-for-beginners/12 - Loops/for.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/python-for-beginners/12 - Loops/for.py b/python-for-beginners/12 - Loops/for.py index 90bf46a5..9ca1aa35 100644 --- a/python-for-beginners/12 - Loops/for.py +++ b/python-for-beginners/12 - Loops/for.py @@ -1,2 +1,10 @@ -for name in ['Christopher', 'Susan']: - print(name) +name = ['Christopher', 'Susan'] ## list of names + +for nm in name: ## This will iterate(in simple words it will fetch the values) the name list one by one till the last element/values reached + print(nm) + +OUTPUT : + Christopher + Susan + +# For better understanding just take a list of numbers( i.e, [0,1,2,3,4,5,6,7,8,9]) and iterate this list using a for loop