Python Forum
Cant multiply sequence by non-int type 'str'
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant multiply sequence by non-int type 'str'
#2
If you are using Python 3.x, input returns a string. You need to convert to integer (or float, if that is what you are expecting).

>>> int('801') == 801
True
>>> 4 * int('27')
108
The float() function does the same for numbers with a decimal part.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Cant multiply sequence by non-int type 'str' - by ichabod801 - Apr-24-2017, 02:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why can't I explicitly call __bool__() on sequence type? quazirfan 11 4,666 Aug-20-2021, 06:49 AM
Last Post: Gribouillis
  Error : "can't multiply sequence by non-int of type 'float' " Ala 3 3,099 Apr-13-2021, 10:33 AM
Last Post: deanhystad
  TypeError: can't multiply sequence by non-int of type 'float' DimosG 3 3,377 Apr-04-2020, 05:16 AM
Last Post: michael1789
  TypeError: can't multiply sequence by non-int of type 'str' emmapaw24 2 2,510 Feb-03-2020, 05:50 PM
Last Post: michael1789
  Type hinting - return type based on parameter micseydel 2 2,510 Jan-14-2020, 01:20 AM
Last Post: micseydel
  TypeError: can't multiply sequence by non-int of type 'str' rregorr 2 2,463 Jun-28-2019, 04:43 PM
Last Post: Yoriz
  TypeError: can't multiply sequence by non-int of type 'str' pythonnoob1234 4 4,308 May-21-2018, 06:12 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020