[Tutor] Python Script

2016-11-09 Thread Jordan Trudell
Hello, I need help running a script, as I am getting an error. Is it possible 
if I could get help with it? Please reply if so.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Question About the .format Method.

2016-11-09 Thread Bryon Adams

Hello,
Working on a simple function to get an IP address and make it look 
pretty for the PyNet course. I'm wondering if there's way to evenly 
space text with the string.format() method similar to how I'm doing it 
with the % operator. The last two prints keep everything left aligned 
and 20 spaces wide. Is there a way to accomplish this with the .format() 
method that I use in the first print function?



# Getting the IP address and putting it into list
ip4 = input('Please enter a /24 network address: ')
ip4 = ip4.split('.') # Split string into a list
ip4 = ip4[:3]# Force list to be a /24 network address
ip4.append('0')
print('{}.{}.{}.{}'.format(ip4[0], ip4[1], ip4[2], ip4[3]))

ip4_str = '.'.join(ip4)
ip4_bin = bin(int(ip4[0]))
ip4_hex = hex(int(ip4[0]))

# Printing the table
print('\n'+'-')
print('%-20s %-20s %-20s' %('NETWORK_NUMBER', 'FIRST_OCTET_BINARY', 
'FIRST_OCTET_HEX'))

print('%-20s %-20s %-20s' %(ip4_str, ip4_bin, ip4_hex))


PS. I realise the first print can be simplified with a .join but I 
forgot about .join and left it to help illustrate my question.


Thanks,
  Bryon
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: IndentationError: unexpected indent

2016-11-09 Thread Joaquin Alzola
>Subject: [Tutor] Fwd: IndentationError: unexpected indent

You are using a mixture of space and tabs or number of spaces.
The exception give you the line that has the problem.

---
Joaquin
This email is confidential and may be subject to privilege. If you are not the 
intended recipient, please do not copy or disclose its content but contact the 
sender immediately upon receipt.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor