Python loop while and for in instances

Source: Internet
Author: User
Python loop while and for in simple instances

#!/uer/bin/env python# _*_ coding:utf-8 _*_lucknumber = 5b = 0while b <3:  print (' Guss count: ', b)  a = Int (input (' You guse number '))  If a > Lucknumber:    print (' Youaerbiger ')  elif a = = Lucknumber:    print (' youare righet ') Break                 # Jump out of this level of the loop  else:    print (' You aer smaller ')  b +=1                  #在while循环中, +=1 is a must loop body else:  print ("Too many Retrys! ") #________________________________________________for I in range (3):  a = Int (input (' guse number '))   # Note that using int () indicates that the output is numeric type  if a > Lucknumber:    print (' Youaerbiger ')  elif a = = Lucknumber:    print (' Youare Righet ')    break  else:    print (' You aer smaller ') Else:  print ("Too many retrys!")

The above Python loop while and for in simple instance is the small part to share all the content of everyone, I hope to give you a reference, but also hope that we have a lot of support topic.alibabacloud.com.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.