Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
64 views
in Technique[技术] by (71.8m points)

How can i remove those in python?

So only useful part of code is

print(gender)
print(age)
print(height)
print(health[randomm])
print(hobby[randomm])
print(phobia[randomm])
print(character[randomm])
print(inventory[randomm])
print(additionalInformation[randomm])
print(cardN1[randomm])
print(cardN2[randomm])

The output is

2
103
199
Ишемическая болезнь сердца

Благотворительность

Авиафобия

Доброта

Набор инструментов

В 1998 году выпил первую бутылку пива.

Поменятся с одним человеком болезнью 1 раз.

Поменяться случайному человеку болезнь.

I copied it right from console and my main question is how i can removes those empty lines?

question from:https://stackoverflow.com/questions/65908558/how-can-i-remove-those-n-in-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the .replace()

string = "Hello 
 World"
print(string.replace("
", ""))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...