Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: More list help please!
Post: RE: More list help please!
(Mar-25-2021, 03:53 PM)michael1789 Wrote: (Mar-25-2021, 03:22 PM)Pytho13 Wrote: I thought this might work:
while len (fruits_1) <5
but it just keeps looping through the code over and over.
W... |
|
Pytho13 |
General Coding Help |
2 |
2,093 |
Mar-25-2021, 04:54 PM |
|
|
Thread: More list help please!
Post: More list help please!
Hi everyone,
I have a question that I can't figure out, I've been trying to find the answer myself.
I have created two lists and looped through them to create the final list
fruits []
I now want ... |
|
Pytho13 |
General Coding Help |
2 |
2,093 |
Mar-25-2021, 03:22 PM |
|
|
Thread: Lists + Empty Lists
Post: RE: Lists + Empty Lists
(Mar-22-2021, 08:49 PM)deanhystad Wrote: What Axel_Erfurt is doing is called slices, and it is how you should extract "slices" from a list. A slice is like this: the_list[start:end]. The slice star... |
|
Pytho13 |
General Coding Help |
15 |
5,490 |
Mar-23-2021, 11:40 AM |
|
|
Thread: Lists + Empty Lists
Post: RE: Lists + Empty Lists
(Mar-22-2021, 07:40 PM)Axel_Erfurt Wrote: You have a list with all days and you want 2 lists with weekdays and weekend days ?
I wrote it before
weekdays = days[:5]
weekends = days[5:]
Thank you ag... |
|
Pytho13 |
General Coding Help |
15 |
5,490 |
Mar-22-2021, 08:20 PM |
|
|
Thread: Lists + Empty Lists
Post: RE: Lists + Empty Lists
Would something like this work:
days = ['Monday','Tuesday', 'Wednesday', 'Thursday','Friday', 'Saturday', 'Sunday']
#Create empty lists for weekdays and weekends
weekdays = []
weekends = []
index... |
|
Pytho13 |
General Coding Help |
15 |
5,490 |
Mar-22-2021, 07:18 PM |
|
|
Thread: Lists + Empty Lists
Post: RE: Lists + Empty Lists
(Mar-22-2021, 06:59 PM)Larz60+ Wrote: Hint:
>>> import calendar
>>> for num, day in enumerate(calendar.day_name):
... print(num, day)
...
0 Monday
1 Tuesday
2 Wednesday
3 Thur... |
|
Pytho13 |
General Coding Help |
15 |
5,490 |
Mar-22-2021, 07:07 PM |
|
|
Thread: Lists + Empty Lists
Post: RE: Lists + Empty Lists
(Mar-22-2021, 06:52 PM)Axel_Erfurt Wrote: They are not empty
weekdays is a new list with the week days
weekends is a new list with the weekend days
I see thank you, do you know a way to assign the ... |
|
Pytho13 |
General Coding Help |
15 |
5,490 |
Mar-22-2021, 06:53 PM |
|
|
Thread: Lists + Empty Lists
Post: RE: Lists + Empty Lists
(Mar-22-2021, 06:47 PM)Axel_Erfurt Wrote: days = ['Monday','Tuesday', 'Wednesday', 'Thursday','Friday', 'Saturday', 'Sunday']
weekdays = days[:5]
weekends = days[5:]
print(weekdays)
print(weekends)... |
|
Pytho13 |
General Coding Help |
15 |
5,490 |
Mar-22-2021, 06:48 PM |
|
|
Thread: Lists + Empty Lists
Post: Lists + Empty Lists
Sorry if this is stupid but I have created a list of days
days = ['Monday','Tuesday', 'Wednesday', 'Thursday','Friday', 'Saturday', 'Sunday']
I am trying to assign the weekdays to an empty list:
w... |
|
Pytho13 |
General Coding Help |
15 |
5,490 |
Mar-22-2021, 06:39 PM |
|
|
Thread: Help with try, except, else finally
Post: RE: Help with try, except, else finally
(Mar-22-2021, 09:52 AM)supuflounder Wrote: Use python tags for code.
Yes, that code looks better.
You are using Polish notation, developed by the Polish mathematician Jan Ćukasiewicz. Most calcul... |
|
Pytho13 |
General Coding Help |
14 |
5,050 |
Mar-22-2021, 11:02 AM |
|
|
Thread: Help with try, except, else finally
Post: RE: Help with try, except, else finally
(Mar-21-2021, 07:17 PM)jefsummers Wrote: Also, if you see a lot of repetitive code (like here), take a step back to see how things can be combined - often in a function, but even easier here. Combin... |
|
Pytho13 |
General Coding Help |
14 |
5,050 |
Mar-22-2021, 11:00 AM |
|
|
Thread: Help with try, except, else finally
Post: RE: Help with try, except, else finally
No, they're not.
Should I move them to surround the try block? and take them off where they are now?
Please see below? **shy**
#User inputs math type
operation = input('''
Please type in the math... |
|
Pytho13 |
General Coding Help |
14 |
5,050 |
Mar-21-2021, 05:55 PM |
|
|
Thread: Help with try, except, else finally
Post: Help with try, except, else finally
Hi everyone,
Nice to meet you all! I'm building a calculator with python and I want to add try except else and finally. I have added the try except and the calculator is working but it doesn't retur... |
|
Pytho13 |
General Coding Help |
14 |
5,050 |
Mar-21-2021, 04:17 PM |