Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: how to return False in ternary condition
Post: how to return False in ternary condition

The code below is running inside a while True loop if play=='y': print('ok') else: return FalseI would like to write those lines in a ternary form. Problem with my code is it seems you cannot ...
KEYS General Coding Help 7 3,068 Dec-08-2020, 10:21 PM
    Thread: increase and decrease a slice value?
Post: RE: increase and decrease a slice value?

You nailed it XD thank you
KEYS General Coding Help 2 2,107 Nov-10-2020, 11:35 PM
    Thread: increase and decrease a slice value?
Post: increase and decrease a slice value?

say i have a list [1,2,3,4,5,6,7] and id like to print, 3,4,5 then 2,3,4,5,6 finally 1,2,3,4,5,6,7 using a for loop, and a slice value within its body is it possible to add to a set slice value? as ...
KEYS General Coding Help 2 2,107 Nov-10-2020, 10:06 PM
    Thread: can you call a function from a list?
Post: RE: can you call a function from a list?

(Nov-10-2020, 05:05 AM)deanhystad Wrote: You can even make a variable that references a function with arguments (look at functools.partial or lambda functions).yes this is what i will need i believe...
KEYS Homework 20 6,233 Nov-10-2020, 06:36 PM
    Thread: can you call a function from a list?
Post: RE: can you call a function from a list?

ok, thank you for the help everyone xd
KEYS Homework 20 6,233 Nov-10-2020, 06:34 PM
    Thread: can you call a function from a list?
Post: RE: can you call a function from a list?

(Nov-09-2020, 10:22 PM)deanhystad Wrote: I think I finally understand what it is you want to do. You want to have a thing that is associated with a function. You would like to be able to say: ruby...
KEYS Homework 20 6,233 Nov-10-2020, 12:27 AM
    Thread: can you call a function from a list?
Post: RE: can you call a function from a list?

(Nov-09-2020, 05:27 AM)buran Wrote: You can iterate over items in a list and apply a fucntion on each item, no need to have the function in a/the list e.g. for item in some_list: some_function(i...
KEYS Homework 20 6,233 Nov-09-2020, 09:16 PM
    Thread: can you call a function from a list?
Post: RE: can you call a function from a list?

(Nov-09-2020, 06:28 PM)deanhystad Wrote: I am leaning towards thinking what you really want are classes. A class is a combination of attributes and behaviors. Your different inventory items probab...
KEYS Homework 20 6,233 Nov-09-2020, 09:09 PM
    Thread: can you call a function from a list?
Post: RE: can you call a function from a list?

(Nov-09-2020, 05:32 AM)perfringo Wrote: I have no idea why or what but I can address this 'adding to list' / 'getting entire function output' part: >>> def my_func(): ... print('Hello ...
KEYS Homework 20 6,233 Nov-09-2020, 05:57 PM
    Thread: can you call a function from a list?
Post: RE: can you call a function from a list?

(Nov-09-2020, 03:49 PM)deanhystad Wrote: I still don't see where a list comes into play. What makes you think you need a list of functions? Are you basing this on your trophy function using multip...
KEYS Homework 20 6,233 Nov-09-2020, 05:53 PM
    Thread: can you call a function from a list?
Post: RE: can you call a function from a list?

Thank you for that reply. I can see you are able to index a single value from the examples but what about the entire iteration of the function. I may be missing something but i dont see a way to store...
KEYS Homework 20 6,233 Nov-09-2020, 05:19 AM
    Thread: can you call a function from a list?
Post: RE: can you call a function from a list?

(Nov-09-2020, 01:47 AM)deanhystad Wrote: What are you trying to do? Describe using terms you know and don't worry about translating to Python. I would like to have a function callable from a list. ...
KEYS Homework 20 6,233 Nov-09-2020, 02:32 AM
    Thread: can you call a function from a list?
Post: can you call a function from a list?

What i am trying to do: create a inventory item that uses a function. The code doesn't work but i will include it as it shows the function i am trying to call on as a list item. def hall(): inv=...
KEYS Homework 20 6,233 Nov-09-2020, 12:31 AM
    Thread: For loop syntax and math on len()
Post: For loop syntax and math on len()

I am curious to know if you are able to divide the len of a string to get a numeric value. I am trying to do this within a for loop. I have two outcomes to the code i would like to write. 1. prints sy...
KEYS General Coding Help 2 1,913 Nov-02-2020, 08:46 PM
    Thread: for loop question
Post: for loop question

Hello, I am trying to find the correct syntax to use in a for loop using an expression as a test condition. The pseudo code i am trying to convert is. Set MyNumber = 7 For (Count = 1; Count <= (M...
KEYS General Coding Help 1 1,737 Oct-27-2020, 11:16 PM
    Thread: while loop question
Post: RE: while loop question

Thanks for the reply, With your notes i was able to re order the code for a working result xd Thanks again. #dice game name = input("what is your name?") print ("Hello!",name) total = 0 money = 100...
KEYS General Coding Help 2 2,025 Sep-26-2020, 11:02 PM
    Thread: while loop question
Post: while loop question

Hello, When my program runs and reaches the winning condition of else: it will print both from the if and else as well as subtract the 1 as if it was a losing value. Need help with the order of operat...
KEYS General Coding Help 2 2,025 Sep-26-2020, 03:28 AM
    Thread: input inbetween two strings?
Post: RE: input inbetween two strings?

(Sep-23-2020, 12:16 AM)scidam Wrote: Take a look at curses module. Not sure, but I think it can be useful for this task. I took a look and at my level of knowledge i dont see anything that can trans...
KEYS General Coding Help 3 2,046 Sep-23-2020, 02:26 AM
    Thread: input inbetween two strings?
Post: input inbetween two strings?

I would like advice on how i can have a second string at the end of the input area in the bellow code. What i am trying to do is have "Enter items weight" _ "lbs" The underscore is were the number wil...
KEYS General Coding Help 3 2,046 Sep-22-2020, 10:42 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020