Questions tagged [except]

Used for the MS .NET LINQ Except() method and the Python except keyword for exception handling. Use the tag sql-except for questions related to the SQL operator EXCEPT

This tag is used for two different things:

  1. The Microsoft [.NET] Framework [LINQ] Except() method which produces set differences of two sequences.

  2. The [Python] keyword except used for exception handling.

Please use the tag for questions related to the SQL operator EXCEPT

598 questions
-1
votes
3 answers

Can you find the even number problem using with try / except?

I didn't understand this thing: list1 = [34,2,1,3,33,100,61,1800] for n in list1: try: n%2 == 0 print(n) except: pass The output of the code above shows every number, but I need just even numbers. What is my…
-1
votes
1 answer

Why doesn't the try/except catch the NameError?

def grades(score): try: if score >= .9: return 'A' elif score >= .8: return 'B' elif score >= .7: return 'C' elif score >= .6: return 'D' elif score <= .59: return 'F' else: return 'Bad Score' except NameError: print('bad score') x =…
-1
votes
1 answer

Try without Except

Is it possible to use try without except? Sometimes it doesn't matter if some iterations crash, but using conditions (maybe more than one) looks weirdly # in my dreams: for i in lines: try: print(i[3])
-1
votes
2 answers

How can I beautifully deal with this dirty-multiple-try code

Hi guys please help me to revise this code. You probably know what I'm trying to do It isn't critical to have keyError but anyway I want to try every del code. It works as I intended, but I'm pretty sure there is more beautiful way to do this. try: …
-1
votes
1 answer

compare two sql table and show which columns are different

I already have the following query which show me the difference between two tables, what I need to find out is that which columns are different , is there any way select * from [10.150.31.22].[database_a].[dbo].[table_a] except select * from…
Sheba Hart
  • 17
  • 3
-1
votes
1 answer

MySQL: Why there has an error when I use EXCEPT to exclude some rows from the original selection?

Credit: Leetcode 1264 Table: Friendship +---------------+---------+ | Column Name | Type | +---------------+---------+ | user1_id | int | | user2_id | int | +---------------+---------+ (user1_id, user2_id) is the primary key…
Margaret H
  • 43
  • 1
  • 7
-1
votes
1 answer

How do I fix this except statement properly?

I'm doing the Collatz Sequence problem from Automate the Boring Stuff for Python and I can't seem to figure out why I can't print 'Please enter an integer' even when I encounter a ValueError. def collatz(number): while number!=1: if…
-1
votes
1 answer

Python3 blows up code always going to try not to except

the code works fine if I first type in some numbers, but blows up if I start with "done" - but I thought the if len(numlist) > 0 would catch that? Also the except blows up? numlist = list() while True: inp = input("Enter a number\n") try: …
-1
votes
2 answers

How to work with try and except in python?

This program has to analyze student numbers and if they are correct write them to one list and if not write them to another list. They are correct if they have eight digits and contain only numbers. I however have no idea what to type when it comes…
-1
votes
1 answer

Split a string by another string except by

I want to split with Regex this line using the separator : except when the segment contains ?: string input = "AV Rocket 456:Contact?:Jane or Tarza:URL?:http?://www.jane.com:Delivered 18?:15:Product Description"; I tried with string pattern =…
-1
votes
1 answer

Python | Pass and Continue statements not resuming loop

What I'm trying to do: I'm essentially running a search procedure with a list of IDs. Those that fail for some reason, I append to a separate list so that I can choose to re-run just those under some different parameters. How I'm trying to do it: #…
-1
votes
2 answers

are there any ways to add ValueError for each input?

So im trying to write a code where you enter the width and height of a rectangle and it gives you the area and perimeter, now obviously the inputs can only be numbers, so i want to be able to ask for another input if the current input is not a…
-1
votes
2 answers

Can I simply "pass" the except block if I catch an error (I dont need to do anything within in it)? What is best practice?

If I catch an error with "try" can I "pass" the "except" statement? Whats best practice? From a get request I am receiving a dictionary which is a string and other times I am getting a string of html. So I am using a try statement to convert the…
M_M
  • 49
  • 1
  • 5
-1
votes
2 answers

catching an input errorr

i made a simple calulator and im trying to catch an error with the try and except function but its not catching the error for some reason. The error is when i put anything other than a number in the num1 or num2 input. Im receiving a ValueError, but…
caleb282
  • 11
  • 3
-1
votes
2 answers

How to reverse a list while preserving the last index?

How I can reverse all the items of a list except the last index? Example: aList = ['1', '2', 'STAY'] And I would want the result to be: aList = ['2', '1', 'STAY']