当前位置:网站首页>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 .
边栏推荐
- Splay
- How are you in the first half of the year occupied by the epidemic| Mid 2022 summary
- CSRF vulnerability analysis
- [Matlab] Simulink 同一模块的输入输出的变量不能同名
- 10、 Process management
- Cobra quick start - designed for command line programs
- 使用block实现两个页面之间的传统价值观
- 一种用于夜间和无袖测量血压手臂可穿戴设备【翻译】
- 2022/02/12
- Estimate blood pressure according to PPG using spectral spectrum time depth neural network [turn]
猜你喜欢
Alibaba cloud international ECS cannot log in to the pagoda panel console
能源行业的数字化“新”运维
Shangsilicon Valley JUC high concurrency programming learning notes (3) multi thread lock
Mathematics in machine learning -- common probability distribution (XIII): Logistic Distribution
Medical image segmentation
Estimate blood pressure according to PPG using spectral spectrum time depth neural network [turn]
Docker installation redis
监控界的最强王者,没有之一!
一种用于夜间和无袖测量血压手臂可穿戴设备【翻译】
Online notes
随机推荐
STM32+HC05串口蓝牙设计简易的蓝牙音箱
朗坤智慧冲刺科创板:年营收4亿 拟募资7亿
Test 123
C#/VB.NET 给PDF文档添加文本/图像水印
There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed
celery最佳实践
【LeetCode第 300 场周赛】
287. Find duplicates
Unity资源顺序加载的一个方法
Grafana 9.0 is officially released! It's the strongest!
2022-2024年CIFAR Azrieli全球学者名单公布,18位青年学者加入6个研究项目
Breadth first traversal of graph
Crawling data encounters single point login problem
How does crmeb mall system help marketing?
线代笔记....
图片缩放中心
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
A wearable arm device for night and sleeveless blood pressure measurement [translation]
Bonecp uses data sources
Method of accessing mobile phone storage location permission under non root condition