Issue raising exceptions – Beginner project /u/benmilesrocks Python Education

Issue raising exceptions – Beginner project /u/benmilesrocks Python Education

Hi everyone!

Trying to make a simple code to handle exceptions. The task is to make a piece of code that checks if an inputted number is between a specified range (in this case -10 to 10). I can make it handle an exception if it falls out of the range, no problem. But I also need a ValueError exception if somebody inputs non numeric values. But I can’t make the ValueError exception work for some reason. Here’s the code:

def read_int(prompt, min, max): try: if prompt in range(min, max): return str(prompt) if prompt not in range(min, max): raise IndexError except IndexError: return “Error: Value not in range ” + str(min) + “, ” + str(max) except ValueError: return “Error: Wrong input” v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v)

v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10)

print(“The number is:”, v)

I’m certain that it’s something REALLY basic that I’m missing here, but I can’t figure it out for the life of me. Please help!!

submitted by /u/benmilesrocks
[link] [comments]

​r/learnpython Hi everyone! Trying to make a simple code to handle exceptions. The task is to make a piece of code that checks if an inputted number is between a specified range (in this case -10 to 10). I can make it handle an exception if it falls out of the range, no problem. But I also need a ValueError exception if somebody inputs non numeric values. But I can’t make the ValueError exception work for some reason. Here’s the code: def read_int(prompt, min, max): try: if prompt in range(min, max): return str(prompt) if prompt not in range(min, max): raise IndexError except IndexError: return “Error: Value not in range ” + str(min) + “, ” + str(max) except ValueError: return “Error: Wrong input” v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v) v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v) I’m certain that it’s something REALLY basic that I’m missing here, but I can’t figure it out for the life of me. Please help!! submitted by /u/benmilesrocks [link] [comments] 

Hi everyone!

Trying to make a simple code to handle exceptions. The task is to make a piece of code that checks if an inputted number is between a specified range (in this case -10 to 10). I can make it handle an exception if it falls out of the range, no problem. But I also need a ValueError exception if somebody inputs non numeric values. But I can’t make the ValueError exception work for some reason. Here’s the code:

def read_int(prompt, min, max): try: if prompt in range(min, max): return str(prompt) if prompt not in range(min, max): raise IndexError except IndexError: return “Error: Value not in range ” + str(min) + “, ” + str(max) except ValueError: return “Error: Wrong input” v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v)

v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10)

print(“The number is:”, v)

I’m certain that it’s something REALLY basic that I’m missing here, but I can’t figure it out for the life of me. Please help!!

submitted by /u/benmilesrocks
[link] [comments]  Hi everyone! Trying to make a simple code to handle exceptions. The task is to make a piece of code that checks if an inputted number is between a specified range (in this case -10 to 10). I can make it handle an exception if it falls out of the range, no problem. But I also need a ValueError exception if somebody inputs non numeric values. But I can’t make the ValueError exception work for some reason. Here’s the code: def read_int(prompt, min, max): try: if prompt in range(min, max): return str(prompt) if prompt not in range(min, max): raise IndexError except IndexError: return “Error: Value not in range ” + str(min) + “, ” + str(max) except ValueError: return “Error: Wrong input” v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v) v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v) I’m certain that it’s something REALLY basic that I’m missing here, but I can’t figure it out for the life of me. Please help!! submitted by /u/benmilesrocks [link] [comments]

Read more

Problems with using list /u/Easy-Paramedic-5611 Python Education

Problems with using list /u/Easy-Paramedic-5611 Python Education

Alright, basically. I am working on a random script to “find clothes” and clothes are in a list. So we got shoes and all such, in a list. All though i can’t seem to figure out how to print only one of the elements in the list. I originally used “` random.choice(clothes) “` but then i couldn’t figure out how to remove that option from the list, because if that is a choice i’d do that instead

submitted by /u/Easy-Paramedic-5611
[link] [comments]

​r/learnpython Alright, basically. I am working on a random script to “find clothes” and clothes are in a list. So we got shoes and all such, in a list. All though i can’t seem to figure out how to print only one of the elements in the list. I originally used “` random.choice(clothes) “` but then i couldn’t figure out how to remove that option from the list, because if that is a choice i’d do that instead submitted by /u/Easy-Paramedic-5611 [link] [comments] 

Alright, basically. I am working on a random script to “find clothes” and clothes are in a list. So we got shoes and all such, in a list. All though i can’t seem to figure out how to print only one of the elements in the list. I originally used “` random.choice(clothes) “` but then i couldn’t figure out how to remove that option from the list, because if that is a choice i’d do that instead

submitted by /u/Easy-Paramedic-5611
[link] [comments]  Alright, basically. I am working on a random script to “find clothes” and clothes are in a list. So we got shoes and all such, in a list. All though i can’t seem to figure out how to print only one of the elements in the list. I originally used “` random.choice(clothes) “` but then i couldn’t figure out how to remove that option from the list, because if that is a choice i’d do that instead submitted by /u/Easy-Paramedic-5611 [link] [comments]

Read more

Ask Anything Monday – Weekly Thread /u/AutoModerator Python Education

Ask Anything Monday – Weekly Thread /u/AutoModerator Python Education

Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread

Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread.

* It’s primarily intended for simple questions but as long as it’s about python it’s allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban.

That’s it.

submitted by /u/AutoModerator
[link] [comments]

​r/learnpython Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread. * It’s primarily intended for simple questions but as long as it’s about python it’s allowed. If you have any suggestions or questions about this thread use the message the moderators button in the sidebar. Rules: Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban. That’s it. submitted by /u/AutoModerator [link] [comments] 

Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread

Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread.

* It’s primarily intended for simple questions but as long as it’s about python it’s allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban.

That’s it.

submitted by /u/AutoModerator
[link] [comments]  Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread. * It’s primarily intended for simple questions but as long as it’s about python it’s allowed. If you have any suggestions or questions about this thread use the message the moderators button in the sidebar. Rules: Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban. That’s it. submitted by /u/AutoModerator [link] [comments]

Read more

Deal says weekend and 3 May (2 weeks) /u/coolman7055 Steam on Reddit

Deal says weekend and 3 May (2 weeks) /u/coolman7055 Steam on Reddit

When I don’t have money black ops 3 goes on sale. I saw that it says weekend deal which is not long enough until I get paid But, it also says 3 may.

Does this mean that the sale is ending on Monday or 3rd of May? This is so I know if I should wait or ask someone for money and pay them back.

submitted by /u/coolman7055
[link] [comments]

​r/Steam When I don’t have money black ops 3 goes on sale. I saw that it says weekend deal which is not long enough until I get paid But, it also says 3 may. Does this mean that the sale is ending on Monday or 3rd of May? This is so I know if I should wait or ask someone for money and pay them back. submitted by /u/coolman7055 [link] [comments] 

When I don’t have money black ops 3 goes on sale. I saw that it says weekend deal which is not long enough until I get paid But, it also says 3 may.

Does this mean that the sale is ending on Monday or 3rd of May? This is so I know if I should wait or ask someone for money and pay them back.

submitted by /u/coolman7055
[link] [comments]  When I don’t have money black ops 3 goes on sale. I saw that it says weekend deal which is not long enough until I get paid But, it also says 3 may. Does this mean that the sale is ending on Monday or 3rd of May? This is so I know if I should wait or ask someone for money and pay them back. submitted by /u/coolman7055 [link] [comments]

Read more
How much have you guys spent? /u/JBags0303 Steam on Reddit

How much have you guys spent? /u/JBags0303 Steam on Reddit

How much have you guys spent? /u/JBags0303 Steam on Reddit

Damn. I did not think I have spent this much on steam in my lifetime but looking at my library, it makes sense. A lot of backlog to get to

submitted by /u/JBags0303
[link] [comments]

​r/Steam Damn. I did not think I have spent this much on steam in my lifetime but looking at my library, it makes sense. A lot of backlog to get to submitted by /u/JBags0303 [link] [comments] 

Damn. I did not think I have spent this much on steam in my lifetime but looking at my library, it makes sense. A lot of backlog to get to

submitted by /u/JBags0303
[link] [comments]   Damn. I did not think I have spent this much on steam in my lifetime but looking at my library, it makes sense. A lot of backlog to get to submitted by /u/JBags0303 [link] [comments]

Read more

how do buy orders work? /u/No-Tourist-3081 Steam on Reddit

how do buy orders work? /u/No-Tourist-3081 Steam on Reddit

I need this to be explained to me in the simplest terms ever

I’ve been looking into buying stuff from the Steam community market and Marketplace.tf, only looking for Team Fortress 2 cosmetics like hats, shirts, accessories, and whatnot. I’m very new to Steam and PC gaming in general and I’m hesitant to go ahead and buy anything without knowing what I’m doing and spending money on something I don’t even know I’ll get. I’ve been trying to use google and look around for some sort of easy explanation to what it is but everything feels way too complicated to me to understand.

submitted by /u/No-Tourist-3081
[link] [comments]

​r/Steam I need this to be explained to me in the simplest terms ever I’ve been looking into buying stuff from the Steam community market and Marketplace.tf, only looking for Team Fortress 2 cosmetics like hats, shirts, accessories, and whatnot. I’m very new to Steam and PC gaming in general and I’m hesitant to go ahead and buy anything without knowing what I’m doing and spending money on something I don’t even know I’ll get. I’ve been trying to use google and look around for some sort of easy explanation to what it is but everything feels way too complicated to me to understand. submitted by /u/No-Tourist-3081 [link] [comments] 

I need this to be explained to me in the simplest terms ever

I’ve been looking into buying stuff from the Steam community market and Marketplace.tf, only looking for Team Fortress 2 cosmetics like hats, shirts, accessories, and whatnot. I’m very new to Steam and PC gaming in general and I’m hesitant to go ahead and buy anything without knowing what I’m doing and spending money on something I don’t even know I’ll get. I’ve been trying to use google and look around for some sort of easy explanation to what it is but everything feels way too complicated to me to understand.

submitted by /u/No-Tourist-3081
[link] [comments]  I need this to be explained to me in the simplest terms ever I’ve been looking into buying stuff from the Steam community market and Marketplace.tf, only looking for Team Fortress 2 cosmetics like hats, shirts, accessories, and whatnot. I’m very new to Steam and PC gaming in general and I’m hesitant to go ahead and buy anything without knowing what I’m doing and spending money on something I don’t even know I’ll get. I’ve been trying to use google and look around for some sort of easy explanation to what it is but everything feels way too complicated to me to understand. submitted by /u/No-Tourist-3081 [link] [comments]

Read more