当前位置:网站首页>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 .
边栏推荐
- Describe the process of key exchange
- 二叉搜索树
- Echart simple component packaging
- 使用map函数、split函数一行键入多个元素
- Shangsilicon Valley JUC high concurrency programming learning notes (3) multi thread lock
- MySQL查询请求的执行过程——底层原理
- 2022/02/12
- Nuc11 cheetah Canyon setting U disk startup
- RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
- 小程序在产业互联网中的作用
猜你喜欢

监控界的最强王者,没有之一!

Xu Xiang's wife Ying Ying responded to the "stock review": she wrote it!

openmv4 学习笔记1----一键下载、图像处理背景知识、LAB亮度-对比度
![[Sun Yat sen University] information sharing of postgraduate entrance examination and re examination](/img/a8/41e62a7a8d0a2e901e06c751c30291.jpg)
[Sun Yat sen University] information sharing of postgraduate entrance examination and re examination

287. 寻找重复数

Medical image segmentation

能源行业的数字化“新”运维

被疫情占据的上半年,你还好么?| 2022年中总结

二叉搜索树

44所高校入选!分布式智能计算项目名单公示
随机推荐
helm部署etcd集群
JDBC驱动器、C3P0、Druid和JDBCTemplate相关依赖jar包
STM32+MFRC522完成IC卡号读取、密码修改、数据读写
10、 Process management
SQL injection Foundation
Blue Bridge Cup real question: one question with clear code, master three codes
44所高校入选!分布式智能计算项目名单公示
Describe the process of key exchange
图之广度优先遍历
A wearable arm device for night and sleeveless blood pressure measurement [translation]
Oracle advanced (IV) table connection explanation
CSRF漏洞分析
node の SQLite
CSRF vulnerability analysis
Alibaba cloud international ECS cannot log in to the pagoda panel console
Certains marchés de l'emploi de Shanghai refusent d'embaucher des personnes qui se rétablissent positives à Xinguan
Stm32+mfrc522 completes IC card number reading, password modification, data reading and writing
Unity资源顺序加载的一个方法
Breadth first traversal of graph
同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人