'Can't multiply sequence by non-int of type 'float' ERROR when trying to multiply a float number with len(list)
I'm trying to take a random sample from a list given SPLIT_SIZE = 0.9
, but I'm having the following error:
TypeError: can't multiply sequence by non-int of type 'float'.
This is the line of code that is giving the error:
list = os.listdir(SOURCE)
training_set = random.sample(list, float(SPLIT_SIZE)*int(len(list)))
where SOURCE
is a directory containing images.
Solution 1:[1]
The second argument of random.sample
have to be integer type.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | heydar dasoomi |