There is a problem on my code, can you fix it please?

I want to make my own!
EDIT:
There is another piece of code to fix. It works fine but not prints anything AT ALL:


from console import clear
from time import sleep
print("Internet Speed Test")
print()
print("Avalible networks: ", "\n", "ENET1", "\n", "local77:\\\\enet")
networks = [
    "ENET1",
    "local77:\\\\enet"
    ]
a = input("What WiFi? ")
if a == networks:
    print("OK")
    sleep(1)
    clear()
    print("Download")
    print("-------------------------------")
    print("844.03 ebs")
    sleep(.1)
    clear()
    sleep(.1)
    print("399.01 ebs")
    clear();sleep(.1)
    print("1k.09 ebs")
    clear();print("OK")
    sleep(1);clear()
    
Output:

Internet Speed Test

Avalible networks:  
 ENET1 
 local77:\\enet
What WiFi? ENET1
>>> 

If you have time to fix it, can you please do it?

In your code a is a string (the result of input()), and you compare it to the list networks, so this comparison is always False.
Perhaps you meant to test if a is in the networks list?
In that case use if a in networks instead of if a == networks.

One could easily get the impression that you want someone else to make it for you.

8 Likes

THERE IS A PROBLEM.

import random

a = random.shuffle(["a", "1", "4", "b", "i", "6", "j", "*"])
print(a)

It prints: None
I am trying to make a code-maker to make a code.

The shuffle function does not return a new copy, it shuffles the input in-place. So it returns None as you saw.

Can you tell me how to fix the problem tho?

Or the solution to this?

I would recommend reading the documentation.

This function will shuffle the input ā€œin-placeā€, without making a copy. That means that if you have a sequence a then it will be re-ordered after a call to random.shuffle(a). But if you pass in a literal sequence (as in your example) you will have no way to view the result because thereā€™s no reference to that list anymore.

Itā€™s a bit complicated for me, can you tell me the simpler way?
The code:

import random

l = ["a", "1", "4", "b", "i", "6", "j", "*"]
a = random.shuffle(l)
print(a)

EDIT:
I am little for the docs, it is too complicated :expressionless:

It shuffles the list in-place. Print out l.

Itā€™s fixed, donā€™t worry

Please read: