+ 1
Upper in if statment
I make list and i put some names then the user will put a name and i want to check if the name exist in the list but in lowecase
5 Antworten
+ 3
Simply:
name = input ("enter the name")
if name in list:
do sth
it searches the name as you entered (whether upper or lower)
+ 3
from my point of view it makes sense to store the names in correct spelling in the list
as we have not full control how user will input a name for search, we convert both (name in list and input) temporarely for comparison to lower() or upper() or casefold()
'''
lst = ['Nora', 'Frank', 'Lisa', 'Dany']
inp = 'franK'
print('found') if inp.lower() in ''.join(lst).lower() else print('not found')
# or instead printing:
if inp.lower() in ''.join(lst).lower():
print('found')
# do something
+ 2
names = ["Jack", "Paul", "Sam"]
find = input("Enter name:- ")
if find.lower() in [x.lower() for x in names[:]]:
print(True)
+ 1
There are several functions to make a string completely uppercase or lowercase :
string = "Hello"
up = string.upper() #HELLO
down = string.lower() #hello
+ 1
use this code:
str=input('please enter name: ')
if str in list:
if str.lower()==str:
print('its lower')
else:
print('its upper')