Hello! I'm new to python (and programming in general) and i need some help in a software I'm currently working with (it's a school project). Basically, I need to receive the ID number and analyse to see if it is in a list I've created previously. However, I'm having problems to do it. I have two lists, one with other list inside (FUNC) and one with some information (Name, ID and Work) (DADOS). Then, I have to receive an ID and see if it is in the sub-list. If it is, i need to remove the sub-list from the big list. However, I cannot do that. When i put the ID (which is in the sublist DADOS), the program say it didnt find the ID there. I'm using the following: py id= input('Put the ID here:').replace('.','').replace('- ','').replace(',','').replace(' ','') if id in func: func.remove('dados') else: print('\033[31mID not found\033[m') id = input('Write the ID again:').replace('.','').replace('-','').replace(',','').replace(' ','')
#๐ How to delete a list in another list by using one of it itens
22 messages ยท Page 1 of 1 (latest)
@atomic birch
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
i'm not so sure it's easier to show - i don't speak your language
i do see a likely problem though:
cpf = input(...)
if 'cpf' in func:
...```
the cpf variable is not used, you create a string made of the characters 'c', 'p', and 'f'
sorry! i edited my post to see if it made more sense. however, i changed the cpf variable right now but nothing changed
EDIT: Inuk had the command to write it
oh sorry ill try
no worries, just makes things look nicer
!code
why is it not colorful
you need the ```py for the first line, just ``` won't give you syntax highlighting
it didnt work
oh. you are a genius, thank you
what do you expect to happen and what happens in practice when you run your code
when i put an ID that does exist in the list "dados", i expect it [dados] to be removed from a bigger list, "func". however, when i put the ID that does exist, for some reason the program acts as if it didnt (it executes the else, not the if), asking me for another ID
are you sure the id is in func?
where is func defined? in the code snippet you've shared, you never push to func
yeah, i know cuz when i ask print(func), the ID is printed
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.