当前位置:网站首页>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 .
边栏推荐
- 十、进程管理
- Afnetworking framework_ Upload file or image server
- Cobra quick start - designed for command line programs
- Shangsilicon Valley JUC high concurrency programming learning notes (3) multi thread lock
- 手写一个的在线聊天系统(原理篇1)
- Implementation of AVL tree
- If you have any problems, you can contact me. A rookie ~
- Echart simple component packaging
- 星诺奇科技IPO被终止:曾拟募资3.5亿元 年营收3.67亿
- Breadth first traversal of graph
猜你喜欢
Some understandings of tree LSTM and DGL code implementation
The role of applet in industrial Internet
二叉搜索树
openmv4 学习笔记1----一键下载、图像处理背景知识、LAB亮度-对比度
Solve DoS attack production cases
Optical blood pressure estimation based on PPG and FFT neural network [translation]
None of the strongest kings in the monitoring industry!
Splay
Numerical analysis: least squares and ridge regression (pytoch Implementation)
测试行业的小伙伴,有问题可以找我哈。菜鸟一枚~
随机推荐
C language college laboratory reservation registration system
Hongke shares | plate by plate ar application in Beijing Winter Olympics
Alibaba cloud international ECS cannot log in to the pagoda panel console
Easy to use PDF to SVG program
287. 寻找重复数
AvL树的实现
图片缩放中心
Xu Xiang's wife Ying Ying responded to the "stock review": she wrote it!
Cocos2d Lua 越来越小样本 内存游戏
使用cpolar建立一个商业网站(1)
Oracle advanced (IV) table connection explanation
Collection of penetration test information -- use with nmap and other tools
AFNetworking框架_上传文件或图像server
Specify flume introduction, installation and configuration
监控界的最强王者,没有之一!
Binary search tree
手写一个的在线聊天系统(原理篇1)
深度循环网络长期血压预测【翻译】
Jushan database was among the first batch of financial information innovation solutions!
同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人