Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to find the unrepeatable combination of three digits in Python

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to find non-repetitive three-digit combinations in Python. The quality of the article is high, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.

Question: There are four numbers: 1, 2, 3 and 4. How many three-digit numbers can be formed without repeating numbers? How many are they?

Program analysis: can fill in hundreds, tens, digits are 1, 2, 3, 4. Make up all the permutations and then remove the permutations that do not meet the conditions.

for i in range(1,5): for j in range(1,5): for k in range(1,5): if( i != k ) and (i != j) and (j != k): print (i,j,k)

Please run in Python 3.

Program output:

1 2 31 2 41 3 21 3 41 4 21 4 32 1 42 3 12 3 42 4 12 4 33 1 23 1 43 2 13 4 24 1 24 1 34 2 14 3 2 How to find non-repeating three-digit combinations in Python is shared here. I hope the above content can be of some help to everyone and can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report