当前位置:网站首页>使用循环语句制作登录程序
使用循环语句制作登录程序
2022-07-17 04:58:00 【算法与编程之美】
0 引言
在python中,我们学习并掌握了for循环,for循环嵌套结构能够帮我们解决身边的一些实际问题。
1 问题
用循环制作登录程序,并且输入3次错误以后报错
(用户名:root密码:sctu)
2 方法
首先需要制作一个循环3次的循环,并且提供input以给用户输入,循环对比用户输入的用户名与密码是否与正确的相匹配。
3 实验结果与讨论
通过实验、实践等证明提出的方法是有效的,是能够解决开头提出的问题。
代码清单 1
for i in range(3): a=str(input("请输入用户名:")) b=str(input("请输入密码:")) if a=="root" and b=="sctu": print("yes") break else: print("用户名或密码错误") |
4 结语
利用循环与input语句能解决生活中更多的实际问题。
边栏推荐
- Eureka, take advantage of the tens of millions of daily visits!
- PHP array_filter去空保留0,false
- TCP/IP 协议
- PHP array_ Filter empty leave 0, false
- C# List 集合对象去重 Linq去重 带时间去重
- Summary of black screen problems in unity UMP packaging
- kettle5.4问题记录
- tidb 学习
- [daily question] sword finger offer II 041 Average value of sliding window
- OpenLDAP自定义schema
猜你喜欢
使用小丸工具箱进行极限视频压缩
Time frequency diagram classification challenge of intelligent hardware voice control 2.0 (ideas and results, currently top5)
MySQL必知必会!!!看这一篇就足够了!!!
MySQL表的查询进阶
[论文精读]BERT
[TA frost wolf \u may- hundred people plan] Introduction to basic rendering lighting (I)
Eureka,拿捏日千万级访问量妥妥的!
Gin framework principle
删除文件 unable to find or create trash dirctory
HighTec 新建 AURIX TC37X demo 工程
随机推荐
而导致公司所有系统修改跟着升级
CKA 核心知识点概述
Reproduction of XOR and encryption decryption
【TA-霜狼_may-《百人计划》】图形2.5 Bump Mapping
[daily question] sword finger offer II 041 Average value of sliding window
手机平台上的用户空间锁概述
Using everything to clean up junk files
Static attributes and static methods of class in JS
Efficient insertion of references in word with thousands of words and many pictures
Eureka, take advantage of the tens of millions of daily visits!
VirtualLab基础实验教程-7.偏振(3)
JS中Class类的静态属性和静态方法
TiDB学习笔记【初阶】
物业小区高校水电抄表充值管理系统
On the third day of security, iptables prevents nmap scanning and binlog
Project structure of wechat applet
[vuforia] simple logic of image recognition
[Unity] Input. Index of gettouch[index]
PHP array_filter去空保留0,false
简洁UI好玩的文字转换emoji表情微信小程序支持句子词语转换_源码