You can concatenate strings using the + operator and repeat them using the * operator:
print( len('abc') ) # Length: number of items print( 'abc' + 'def' ) # Concatenation: a new string print( 'Ni!' * 4 ) # Repetition: like "Ni!" + "Ni!" + ... # ww w. j a v a 2 s. c om
The len built-in function returns the length of a string.
Adding two string objects with + creates a new string object, with the contents of its operands joined.
Repetition with * is like adding a string to itself a number of times.
To print a line of 80 dashes, you can count up to 80, or let Python count for you:
print('-' * 80) # 80 dashes, the easy way