Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I want to print the pattern
hello! 10 8 6 4 2
I have written the following code
print "Hello!"; num=10; while(num>=2) print num; num-=2;
Upon execution it is showing syntax error at line 1..
syntax error at line 1..
while num >= 2:
First of all, do not use semicolons in Python code. There are 2 ways to do this.
1) Using While Loop -
print "Hello!" num = 10 while num >= 2: print num num -= 2
2) Using For loop -
print "Hello!" for i in range(10, 1,-2): print i
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
while num >= 2: