Python Forum
Basic input() function question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic input() function question
#3
@wavic
using if not any is wrong and would yield the opposite result
name = 'test'
inappropriate = "<>#!@$%^&*()_- {}"
if not any(map(lambda char: char in inappropriate, name)):
    print('invalid')
Output:
invalid
and there is no need to complicate it with using lambda, keep it simple

inappropriate = "<>#!@$%^&*()_- {}"
if any(char in inappropriate for char in name):
    # The name is not alright.
Reply


Messages In This Thread
Basic input() function question - by rebubula76 - Nov-27-2017, 02:46 AM
RE: Basic input() function question - by wavic - Nov-27-2017, 07:47 AM
RE: Basic input() function question - by buran - Nov-27-2017, 08:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between forms of input a list to function akbarza 6 1,156 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  Basic Coding Question: Exit Program Command? RockBlok 3 647 Nov-19-2023, 06:31 PM
Last Post: deanhystad
  Question on dir() function Soorya25 1 1,207 Jan-16-2023, 09:33 PM
Last Post: deanhystad
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,162 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Function not scriptable: Noob question kaega2 3 1,239 Aug-21-2022, 04:37 PM
Last Post: kaega2
  Showing an empty chart, then input data via function kgall89 0 1,004 Jun-02-2022, 01:53 AM
Last Post: kgall89
  [solved] Basic question on list matchiing paul18fr 7 1,952 May-02-2022, 01:03 PM
Last Post: DeaD_EyE
  input function question barryjo 12 2,869 Jan-18-2022, 12:11 AM
Last Post: barryjo
  function with 'self' input parameter errors out with and without 'self' called dford 12 3,255 Jan-15-2022, 06:07 PM
Last Post: deanhystad
Big Grin General programming question (input string)[ jamie_01 2 1,650 Jan-08-2022, 12:59 AM
Last Post: BashBedlam

Forum Jump:

User Panel Messages

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