Skip to content

Pls explain how to write a loop code #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
La-victoire opened this issue Jul 3, 2022 · 2 comments
Open

Pls explain how to write a loop code #1594

La-victoire opened this issue Jul 3, 2022 · 2 comments

Comments

@La-victoire
Copy link

No description provided.

@MahikaKakani
Copy link

for variable in range(start,stop,jump): print(variable)

For example:

for x in range(0,5): print(x)

Output:
0
1
2
3
4

Second example:

for x in "smile": print(x)

Output:
s
m
i
l
e

@MahikaKakani
Copy link

MahikaKakani commented Jul 5, 2022

while condition: #write code here # change the condition i.e. any increment or decrement possible

For example:

i=0 while i<=5: print("Hi ",i) i=i+1

Output:
Hi 0
Hi 1
Hi 2
Hi 3
Hi 4
Hi 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants