+ 1

Как поставить пробел между цифрой в питоне?

Здравствуйте. Подскажите как сделать в питоне так что пользователь вводит число любое двух значение число, а выводит ему тоже число только с пробелом по середине? Пример: 23, Должен быть вывод: 2 3

7th Apr 2023, 7:16 PM
Misharik
Misharik - avatar
4 Answers
+ 1
Здравствуй. Я вот так бы сделал: num = input() print(num[0] + " " + num[1])
7th Apr 2023, 9:48 PM
Lamron
Lamron - avatar
+ 5
num = 23 print(num[0], num[1])
8th Apr 2023, 7:11 AM
JaScript
JaScript - avatar
+ 2
num = input()or'123' print(' '.join(num))
8th Apr 2023, 9:11 PM
Solo
Solo - avatar
0
To put a space between numbers in Python, you can easily do it by converting the numbers to strings and using the .join() method. For example, you could use print(' '.join(str(number) for number in numbers_list)) to add a space between each number in a list. Python is incredibly flexible when it comes to formatting data! If you’re running a website or blog about programming tutorials, you should https://rank1pro.com/digital-marketing/seo-search-engine-optimization/ to help increase your visibility online. Optimizing your content for search engines will help more people find useful tips like this one!"
23rd Oct 2024, 8:54 PM
stevensmith