Why does importing from random in python give me back unused import statement?

Question:

When I type for ex:

from random import shuffle

I get:
Unused import statement ‘from random import shuffle’
in return and the letter go grey. Can anybody diagnose?

I tried "from random import shuffle" and was expecting to be able to use shuffle

Asked By: rootman0

||

Answers:

Without seeing the rest of the code I think that the error description is correct. Your import is unused. That means that you imported it but in the actual script the shuffle function was never accessed.

Try using it in your code:

from random import shuffle

my_shuffled_number = shuffle([1, 2, 3, 4, 5])

print(my_shuffled_number)

This small script makes use of the import function.

Answered By: Luca Zangari
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.