String Formatting in Python

striplstriprstripformatzfillljustrjust
Задание 1

Given a string:

pythontxt = 'a1bc11de'

Remove all ones from the string to get the following result:

python['a', 'b', 'c', 'd']
Задание 2

Given a string with trailing spaces:

pythontxt = ' abcde '

Remove spaces from the ends:

python'abcde'
Задание 3

Given a string with trailing spaces:

pythontxt = ' abcde '

Remove spaces on the left:

python'abcde '
Задание 4

Given a string with trailing spaces:

pythontxt = ' abcde '

Remove spaces on the right:

python' abcde'
Задание 5

Given a string with trailing spaces:

pythontxt = ' abcde '

Remove spaces on the right:

python' abcde'
Задание 6

Given a string and a number:

pythontxt = 'abc {}'
num = 12

Substitute a number in place of the curly brackets in the line.

Задание 7

Let's say you have a string variable with a username followed by curly braces. Pass in the user's age using the variable age.

Задание 8

Given an empty string:

pythontxt = ''

Given a variable:

pythonnum = 6

Write as many zeros into the line as the value contained in our variable:

python'000000'
Задание 9

Given a string:

pythontxt = 'abcde'

Write the code to get the following result:

python'abcde111'
Задание 10

Given a string:

pythontxt = '12345'

Write the code to get the following result:

python'aa12345'