Search code examples
pythonfloating-pointsequencemultiplication

Multiplying a string with a float


So, I am very new to python but have done a little bit of programming in matlab. So now i have two values that i want to multply by the same constant, for example:

res = 1920, 1080

win_scale = 1/1.25

width, height = res*win_scale

which gives me the error: "can't multiply sequence by non-int of type 'float'"

I have found other related questions but none that I can understand. Thank you


Solution

  • Assuming you want each value in res multiplied by the float:

    width, height = [x * win_scale for x in res]