+ 1
How to make the programmes ignore capitalization and space?
like input aac, Aac,AaC etc will give the same result.
5 Réponses
+ 3
Did you meant in strings ?
to remove spaces :
print("Hello World".replace(" ",""));
to equalize although cases are equal:
print("A".capitalize()=="a".capitalize());
+ 2
name = input().lower().replace(" ", "")
print(name)
+ 2
If you want the user to enter a command like chose(add, sub,mul, div) and the user enters Add if you use .lower() on the variable it converts it to lowercase and will then == add. same with .replace() it replaces the first arg with the second in this case a space " " with no space "". They are built in functions. .upper() would also work by making the input all uppercase in the case you wanted to compare it to say ADD
+ 1
you need to convert your every input into lower case or according to your need.it will produce right and same result every time.
e.g
x=input()
print(x.lower()) #if x is ABC or AbC or abc it will always give abc.
but remember that your code should be work with lower case letter.
0
can you explain