Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I can't understand where is the error in this python code ( Kahoot.py)

I’m making a kahoot botter and this is the code:

from colorama import Fore
from kahoot import client
import pyfiglet
import sys


def joinHandle():
    pass


print(Fore.BLUE + pyfiglet.figlet_format("Kahoot Bot"))
print(Fore.BLUE + "Coded by AsyncCode <3  | https://discord.gg/99KDZYwn2c")
username = input(Fore.BLUE + "Tell me the Bots name. > ")
code = input(Fore.BLUE + "Tell me the Kahoot's Game Code. > ")
int(code)
if code.isdigit() is False:
  print(Fore.BLUE + "Error, the Code must be an Integer.")
  sys.exit(1)
logging = input(Fore.BLUE + "Tell me if you want to enable logging. y / n > ")

bots = input(Fore.BLUE + "How many bots do you want? ")
for x in bots:
    bot = client()
    BotID = x
    BotID = str(BotID)
    bot.join(code, username + " - " + BotID)
    bot.on("joined", joinHandle)
    if logging == "y":
      print(Fore.BLUE + "Log: Joining the Game (" + code + ") with Name: " + username + " - " + BotID + ".")
    BotID = int(BotID)

If i enter 10 it will make bot – 1 and bot – 0 and not a range from 1 to ten

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The bots variable is a string:

bots = input(Fore.BLUE + "How many bots do you want? ")

Your current code iterates over each character in the string.

Assuming you want to run as many iterations as the input value, you should first convert the string to an integer, and then iterate over a range with the same length as this integer:

bots = int(input(Fore.BLUE + "How many bots do you want? "))

for i in range(bots):
   ...
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading