M
M
Maruf2021-06-25 20:05:24
Python
Maruf, 2021-06-25 20:05:24

How to move all code to 1 line?

Help, I need to make all this code so that it is in one line

name = input("Enter your first name!")
surname = input("Enter your last name!")
date_of_birth = input("Enter your date of birth!")
username = input("Enter your username!")
password = input("Enter your password!")
print(name, surname)
print(date_of_birth)
print(username, password)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Ramis, 2021-06-25
@Maruf995

Is that so

print(input("Введите ваше имя!"));print(input("Введите вашу фамилию!")); print(input("Введите дату рождения!"));print(input("Введите имя пользователя!"));print(input("Введите пароль!"))

V
Vladimir Kuts, 2021-06-25
@fox_12

Crazy task:

name, surname, date_of_birth, username, password = input("введите имя фамилию ... через пробелы").split();print(name,surname,date_of_birth,username,password)

D
Dmitry, 2021-06-25
@LazyTalent

Easy!

print(
    " ".join([input(f"Input your {i}: ") for i in ["name", "last name"]])
    + "\n"
    + input("Input your birth date: ")
    + "\n"
    + " ".join([input(f"Input your {i}: ") for i in ["user name", "password"]])
)

# Input your name: di
# Input your last name: k
# Input your birth date: 26
# Input your user name: w
# Input your password: sakfjs
# di k
# 26
# w sakfjs

M
MinTnt, 2021-06-25
@MinTnt

Well, there are various ways, but if you need exactly what the code above does.

[(print(name, surname), print(date_of_birth), print(username, password)) for name, surname, date_of_birth, username, password in [ [input(f"Введите {ts}") for ts in ('ваше имя!', 'вашу фамилию!', 'дату рождения!', 'имя пользователя!', 'пароль!')] ] ]

Ps Well, well, I made a small reminder for myself on this case https://vk.com/@mintnt-oneline-code-python

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question