@hairinmybellybutt to Programmer [email protected]English • 1 year agowould you write web app with this?imagemessage-square53arrow-up1286arrow-down133
arrow-up1253arrow-down1imagewould you write web app with this?@hairinmybellybutt to Programmer [email protected]English • 1 year agomessage-square53
minus-squaretryptaminev 🇵🇸 🇺🇦 🇪🇺linkfedilink9•1 year agoexample: i = 5.0//2 list[i] throws an error because i is double and the list-index expects an integer. so for it to work the code needs to look like this: i = int(5.0//2) list[i] meanwhile this works: i=5 i= ‘abcde’
minus-square@[email protected]linkfedilink3•1 year agoIt is but if you start with a float you get a float back.
minus-square@[email protected]linkfedilink1•1 year agoWas really surprised by this too, because iirc Python 2 did not do this.
example:
throws an error because i is double and the list-index expects an integer.
so for it to work the code needs to look like this:
meanwhile this works:
Isn’t
//
integer division?It is but if you start with a float you get a float back.
You’re right, I did not know that. Thanks!
Was really surprised by this too, because iirc Python 2 did not do this.
you can do
i: int
to make this error outNo, type hints are not enforced.
damn