0

Generalize string output in python

Anyone who can assist please how do I generalize syntax to print 1st and last work of a string in python, from an unknown user input? #newbie

18th Jul 2019, 6:52 AM
Tatenda
Tatenda - avatar
5 Respuestas
+ 3
s = str(input()).split(" ") print(s[0], s[-1]) #input: this is a string #output: this string
18th Jul 2019, 7:04 AM
Jake
Jake - avatar
+ 4
# txt = input() txt = "Hello world" print(txt[0], txt[-1]) # H d
18th Jul 2019, 6:58 AM
Diego
Diego - avatar
+ 3
txt = input()
18th Jul 2019, 7:00 AM
Anton Böhler
Anton Böhler - avatar
+ 1
first and last letter actually , my bad
18th Jul 2019, 9:15 AM
Tatenda
Tatenda - avatar
0
First and last 'work'?
18th Jul 2019, 8:56 AM
HonFu
HonFu - avatar