Task: Write a hangman game in Python.
Problem: You must select the first and last letters in the word.
Question: How to choose the first and last letter in a word in Python?
|
2 answers
first, last = word[0], word[-1] - It can be mentioned that in general, to break a word into letters, it is useful to know about Unicode normalization, grapheme clusters. To divide 3 words into characters in Python - jfs
|
arguments packing / unpacking
# 'д' [] 'а' (first, *middle, last) = 'да' # 'с' ['л', 'о', 'в'] 'о' (first, *middle, last) = 'слово' # first="с", f="л", m="['о']", l="в", last="о" (first, *(f, *m, l), last) = 'слово' print('first="{first}", f="{f}", m="{m}", l="{l}", last="{last}"'.format(**vars())) |