Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Stupidity, like virtue, is its own reward" -- William E. Davidsen


devel / comp.lang.python / Re: code confusion

SubjectAuthor
o Re: code confusiondn

1
Re: code confusion

<mailman.108.1650008996.20749.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=22258&group=comp.lang.python#22258

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonList@DancesWithMice.info (dn)
Newsgroups: comp.lang.python
Subject: Re: code confusion
Date: Fri, 15 Apr 2022 19:49:35 +1200
Organization: DWM
Lines: 28
Message-ID: <mailman.108.1650008996.20749.python-list@python.org>
References: <CAD9v3s=Zz165CknTu7ZS6LRWqqmCtdL=ymh3QpmuaqAfC3aVgw@mail.gmail.com>
<8fc44be5-12ff-94e6-b155-319f201c00e2@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de pLtMCWEjozADPH237gLJsQv4vRvS+i+DgI7GKyJUt/ZQ==
Return-Path: <PythonList@DancesWithMice.info>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=danceswithmice.info header.i=@danceswithmice.info
header.b=nCrvaFH7; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.015
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'used.': 0.07; '=dn': 0.09;
'from:addr:danceswithmice.info': 0.09; 'from:addr:pythonlist':
0.09; 'message-id:@DancesWithMice.info': 0.16; 'question,': 0.16;
'received:51.254': 0.16; 'received:51.254.211': 0.16;
'received:51.254.211.219': 0.16; 'received:cloud': 0.16;
'received:rangi.cloud': 0.16; 'subject:code': 0.16; 'wrote:':
0.16; 'to:addr:python-list': 0.20; 'code': 0.23; 'discussion':
0.25; 'header:User-Agent:1': 0.30; 'header:Organization:1': 0.31;
'question': 0.32; 'received:192.168.1': 0.32; 'there': 0.33;
"didn't": 0.34; 'mean': 0.34; 'header:In-Reply-To:1': 0.34;
'functions': 0.36; 'using': 0.37; 'received:192.168': 0.37;
'could': 0.38; 'use': 0.39; 'methods': 0.39; 'chat': 0.61;
'received:51': 0.64; 'well': 0.65; 'received:userid': 0.66;
'major': 0.78; 'struggle': 0.84
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 814EA966A
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1650008989;
bh=9w+npf76H7n5v5w3nisnjxXNBS/kr7NXfYh5nFgfrhQ=;
h=Date:Subject:To:References:From:In-Reply-To:From;
b=nCrvaFH78HJngwnAJ39qxKdT/2E84zTo6vRPNxRjPPRnCvaDpM6ZGi6Ai2mprkXYy
vSIC70F1tgEm+oB9xcyELoKCrQGHYZXN6ICaCPW9nWkaF58HkkB9AOifI7kt+JVyDw
N0dWIS9bpyovJuAv2jCH06l4JiCTB5SP95WuAPCDUpQG/77/qGTlF64EcQZx6WD1LU
RuS+644kQ49qoDv8fDnZYnlmkPHNyNLoDVBteMk6hCYOXzBhdFkJFv6fQb9+NQsarT
xL5RX8OKSlAG0smHD43ZN1eKq5/k6/hDgg3fKbFxzibJSJpvia1XG51eq0KScELHAh
hvgudTClGWi9Q==
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on vps517507.ovh.net
X-Spam-Level:
X-Spam-Status: No, score=-6.9 required=5.0 tests=ALL_TRUSTED,BAYES_00,
DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,NICE_REPLY_A,T_SCC_BODY_TEXT_LINE
autolearn=ham autolearn_force=no version=3.4.0
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 94B429517
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1650008988;
bh=9w+npf76H7n5v5w3nisnjxXNBS/kr7NXfYh5nFgfrhQ=;
h=Date:Subject:To:References:From:In-Reply-To:From;
b=ln0VLRlTPNbg1NI7bcSDkEN6cWWAy1TUzDrpyk10+LhU+AO9brBMUKQ/jTe6wDdoB
yg4E1JjYGOVmeWYx7u8MY4O6m9MFmTuapThi6W1GzeKdpkiBNm1RBQV2hXnpAd5Uk1
TuNBX7AdjS9Z47ErP0wpKsq94gF4MSPh4hVEEfkrtrwuekrESDFkgCm/SaO/PRivS2
FHP5Ir8I4y0dZBY00bq3fTwP7dzqK8ii1sk2e5w4e9UbUaV3osm8sS7rg7huuoeT98
wxbAoglT+FbJUJs9XaGa9etgCBjX5SzuMfIcpdTiE1WE8QCDLWYqZ0OmzChiIw8bcI
69JtsQ+4kCwug==
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Content-Language: en-GB
In-Reply-To: <CAD9v3s=Zz165CknTu7ZS6LRWqqmCtdL=ymh3QpmuaqAfC3aVgw@mail.gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <8fc44be5-12ff-94e6-b155-319f201c00e2@DancesWithMice.info>
X-Mailman-Original-References: <CAD9v3s=Zz165CknTu7ZS6LRWqqmCtdL=ymh3QpmuaqAfC3aVgw@mail.gmail.com>
 by: dn - Fri, 15 Apr 2022 07:49 UTC

On 15/04/2022 19.41, Tola Oj wrote:
> i = int(input())
> lis = list(map(int,input().strip().split()))[:i]
> z = max(lis)
> while max(lis) == z:
> lis.remove(max(lis))
>
> print (max(lis))
>
> this is an answer to a question from the discussion chat in hackerrank. i
> didn't know the answer so i found an answer that fitted well to the
> question, however i struggle to understand the use of some of the methods
> and functions the person has used. my major questions are: 1. what does
> "[:i]" mean
> 2. is there
> another i could write this code using if statement?
> thank you

It is taking a slice from the list:
https://docs.python.org/3/glossary.html#term-slice

More explanation:
https://docs.python.org/3/tutorial/introduction.html?highlight=slice

--
Regards,
=dn


devel / comp.lang.python / Re: code confusion

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor