Skip to main content

Get the Reddit app

Scan this QR code to download the app now
Or check it out in the app stores

r/learnpython

members
online

Ask Anything Monday - Weekly Thread

Please Help Please Help
Please help idk what to do

from aiogram import Bot, Dispatcher, types

bot = Bot(token='7110113184:AA******************')
dp = Dispatcher(bot)

u/dp.message_handler(commands=['start'])
async def start(message: types.Message):
    await message.reply("Ajderadi vise u picku materinu")

@dp.message_handler()
async def say(message: types.Message):
    await message.answer(message.text)
    await dp.feed_update(bot=bot, update=incoming_update)

This shows up

dp = Dispatcher(bot)
TypeError: Dispatcher.__init__() takes 1 positional argument but 2 were given

Why won't my file open? and why is this program trying to read my input as something it isn't? Why won't my file open? and why is this program trying to read my input as something it isn't?

part 1:

I managed to get it to read the first line of the file so I know I can access the file. But now, it will not open.

def boyFiles():
try:
    with open('BoyNames.txt', 'r') as boy_names:
        boy_list= []
        for line in range(len(boy_names)): 
            line = line.strip()
            boy_list.append(line)
    print('Boys names have been added to the list successfully')
    print(boy_list)
except:
    print('error opening the boys file')

The result was my code saying " error opening the boys file" and it went on to the next function.

Part 2:

then NameError: name 'search' is not defined for the following function:

def userInput():
search = input("Please enter a name to search or press 'x' to exit the program.")
name_search = search.lower()
if name_search == "x":
    exit
return(search, name_search)