当前位置:网站首页>Use map function and split function to type multiple elements in one line
Use map function and split function to type multiple elements in one line
2022-07-06 18:46:00 【Beauty of algorithm and programming】
How to solve the problem that requires two or more unknowns to be input in one line at the same time .
1 problem
In the current study , We have encountered some problems that require two or more unknowns to be entered in a row at the same time , But what we learned input Functions are difficult to solve .
2 Method
First , We input unknown names that need to be input at the same time from the keyboard , recycling map Function plus input Function plus split The function defines the unknowns that need to be typed .
3 Experimental results and discussion
Through the experiment 、 Practice has proved that the proposed method is effective , Is able to solve the problem raised at the beginning .
Code list 1
num1,num2 = map(int,input().split()) #split The following parentheses are empty , So wait, separate with spaces , If you use split(“,”), Then it is separated by commas print(num1,num2) |
4 Conclusion
This article mainly introduces the utilization map function 、split Function to solve the problem of typing multiple numbers at the same time , in addition , If you want to add the number you typed directly to the list , Can be in map Preceded by brackets . This article only introduces one method , Here's a good example , Welcome to share other methods .
边栏推荐
猜你喜欢
Hongke shares | plate by plate ar application in Beijing Winter Olympics
Medical image segmentation
关于npm install 报错问题 error 1
Binary search tree
线代笔记....
helm部署etcd集群
人体骨骼点检测:自顶向下(部分理论)
44所高校入选!分布式智能计算项目名单公示
Nuc11 cheetah Canyon setting U disk startup
[Sun Yat sen University] information sharing of postgraduate entrance examination and re examination
随机推荐
STM32+ENC28J60+UIP协议栈实现WEB服务器示例
Introduction and case analysis of Prophet model
Penetration test information collection - App information
【中山大学】考研初试复试资料分享
Implementation of AVL tree
ORACLE进阶(四)表连接讲解
基于ppg和fft神经网络的光学血压估计【翻译】
Penetration test information collection - CDN bypass
重磅硬核 | 一文聊透对象在 JVM 中的内存布局,以及内存对齐和压缩指针的原理及应用
Echart simple component packaging
Celery best practices
Cocos2d Lua smaller and smaller sample memory game
具体说明 Flume介绍、安装和配置
2022/02/12
Installation and management procedures
UFIDA OA vulnerability learning - ncfindweb directory traversal vulnerability
celery最佳实践
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
About NPM install error 1
Cocos2d Lua 越来越小样本 内存游戏