当前位置:网站首页>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 .
边栏推荐
猜你喜欢
爬虫玩得好,牢饭吃到饱?这3条底线千万不能碰!
Use cpolar to build a business website (1)
Visual Studio Code启动时提示“Code安装似乎损坏。请重新安装。”、标题栏显示“不受支持”信息的解决办法
Mathematics in machine learning -- common probability distribution (XIII): Logistic Distribution
Handwritten online chat system (principle part 1)
287. Find duplicates
Medical image segmentation
当保存参数使用结构体时必备的开发技巧方式
SAP Fiori 应用索引大全工具和 SAP Fiori Tools 的使用介绍
[the 300th weekly match of leetcode]
随机推荐
关于npm install 报错问题 error 1
使用cpolar建立一个商业网站(1)
POJ 2208 six lengths of tetrahedron are known, and the volume is calculated
Brief description of SQL optimization problems
Stm32+esp8266+mqtt protocol connects onenet IOT platform
UFIDA OA vulnerability learning - ncfindweb directory traversal vulnerability
基于蝴蝶种类识别
Picture zoom Center
抽象类与抽象方法
MySQL查询请求的执行过程——底层原理
Jushan database was among the first batch of financial information innovation solutions!
On AAE
10、 Process management
Example of implementing web server with stm32+enc28j60+uip protocol stack
Penetration test information collection - basic enterprise information
Penetration test information collection - CDN bypass
Interpreting cloud native technology
【LeetCode第 300 场周赛】
星诺奇科技IPO被终止:曾拟募资3.5亿元 年营收3.67亿
Medical image segmentation