Multiplying a string with a number results in “TypeError: can't multiply sequence by non-int of type 'str'”

后端 未结 5 854
Happy的楠姐
Happy的楠姐 2020-12-03 03:16

I need a string consisting of a repetition of a particular character. At the Python console, if I type:

n = \'0\'*8

then n gets

5条回答
  •  既然无缘
    2020-12-03 03:54

    I could bet you're using raw_input() to read the value which multiplies the string. You should use input() instead to read the value as an integer, not a string.

提交回复
热议问题