Python loop while and forin instances

Source: Internet
Author: User
The following is a simple example of python loop while and forin. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at it with Xiaobian. Python loop while and for in simple instances

#! /Uer/bin/env python # _ * _ coding: UTF-8 _ * _ lucknumber = 5b = 0 while 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 loop else: print ('You aer smaller ') B + = 1 # in the while loop, + = 1 is a must loop body else: print ("Too required retrys! ") # ________________________________________________ For I in range (3): a = int (input ('You guse number') # Use int () indicates that the output is of the numeric type if a> lucknumber: print ('youaerbiger ') elif a = lucknumber: print ('youare righet') break else: print (you aer smaller ') else: print ("Too success retrys! ")

The above python loop while and for in is a simple example of all the content shared by Xiaobian. I hope to give you a reference and support for PHP.

For more articles about python loop while and for in instances, please follow the PHP Chinese network!

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.