Welcome to the Treehouse Community
Looking to learn something new?
ANGEL SERRANO PEREZ9,855 Points
I dont know how to check capitalization and how to check if a part of a text is inside of another text
from django import forms from django.core import validators def not_treehouse(value): if '@teamtreehouse.com' in value: raise forms.ValidationError('no tree') class LeadShareForm(forms.Form): email = forms.EmailField(validators=[not_treehouse]) link = forms.URLField() honeypot = forms.CharField(widget=forms.HiddenInput,required=False) def clean_honeypot(self): honey = self.cleaned_data['honeypot'] if len(honey): raise forms.ValidationError('Bad robot!') return honey
Steven Parker215,984 Points
Remember, you're not just checking if it's inside, you want to check if it is at the end. And you don't necessarily have to check capitalization if you can somehow be sure the case is what you want.
Python strings have a number of handy built-in methods. One of them is .endswith(), which checks to see if the string ends with another string. And of course, you can always change a string to lower case with the .lower() method. And, you can chain methods together if you want to do more than one of them to the same string.
I'm betting with these hints you can figure it out.