unindent与任何外部缩进级别Coursera赋值不匹配

时间:2016-10-04 15:34:47

标签: python python-3.x

大家好我刚开始使用Python(3.5)尝试在Coursera上完成作业并且我一直收到上述错误

Age = 15
if Age >=15 :
    print ("Highschool")
   else if
       print ("No HighSchool")

2 个答案:

答案 0 :(得分:1)

Python与许多编程语言不同,它依赖于缩进来规定范围。特别是,它允许标签或一定数量的空格来指示范围。具有相同缩进级别的连续行都在相同的范围内。

您的代码:

Age = 15
if Age >=15 :
    print ("Highschool")
   else if
       print ("No HighSchool")

缩进是不均匀的,这会让python解释器感到困惑。您似乎使用4个空格来表示缩进,但是您的else if语句(顺便说一下应该是else:)不是任何有意义的缩进级别。在else if语句之前使用3个空格。实际上你应该使用0个空格,因为它在if语句的相同范围/级别上运行。

Age = 15
if Age >=15 :
    print ("Highschool")
else:
    print ("No HighSchool")

详细了解Python的空白here

答案 1 :(得分:0)

问题是匹配valgrind --track-origins=yes ./minibsdiff gen ivanTestBin/setup1.exe ivanTestBin/setup2.exe ivanTestBin/setuppatch ==5460== Memcheck, a memory error detector ==5460== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==5460== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info ==5460== Command: ./minibsdiff gen ivanTestBin/setup1.exe ivanTestBin/setup2.exe ivanTestBin/setuppatch ==5460== ==5460== Conditional jump or move depends on uninitialised value(s) ==5460== at 0x4167F8: _int_free (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x460808: fillin_rpath (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x460E04: _dl_init_paths (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x43C0E3: _dl_non_dynamic_init (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x43C9B7: __libc_init_first (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x4059E4: (below main) (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== Uninitialised value was created ==5460== at 0x45DF09: brk (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x43A1D8: sbrk (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x406106: __libc_setup_tls (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x40599C: (below main) (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== ==5460== Conditional jump or move depends on uninitialised value(s) ==5460== at 0x41684D: _int_free (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x460808: fillin_rpath (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x460E04: _dl_init_paths (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x43C0E3: _dl_non_dynamic_init (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x43C9B7: __libc_init_first (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x4059E4: (below main) (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== Uninitialised value was created ==5460== at 0x45DF09: brk (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x43A1D8: sbrk (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x406106: __libc_setup_tls (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x40599C: (below main) (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== ==5460== Conditional jump or move depends on uninitialised value(s) ==5460== at 0x416248: malloc_consolidate (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x417D36: _int_malloc (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x419D20: malloc (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x45884F: _IO_file_doallocate (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x413A93: _IO_doallocbuf (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x412C97: _IO_file_overflow (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x4120A3: _IO_file_xsputn (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x44AA63: vfprintf (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x40C445: printf (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x4054C3: diff (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x4057CA: main (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== Uninitialised value was created ==5460== at 0x45DF09: brk (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x43A1D8: sbrk (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x406106: __libc_setup_tls (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== by 0x40599C: (below main) (in /home/ivan/ota/binary_diff_tools/bsdiff-master/minibsdiff-master/minibsdiff) ==5460== Generating binary patch between ivanTestBin/setup1.exe and ivanTestBin/setup2.exe Old file = 967168 bytes New file = 965632 bytes Computing binary delta... sizeof(delta('ivanTestBin/setup1.exe', 'ivanTestBin/setup2.exe')) = 39922 bytes Successfully created patch; patch file name: ivanTestBin/setuppatch ==5460== ==5460== HEAP SUMMARY: ==5460== in use at exit: 0 bytes in 0 blocks ==5460== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==5460== ==5460== All heap blocks were freed -- no leaks are possible ==5460== ==5460== For counts of detected and suppressed errors, rerun with: -v ==5460== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0) 的{​​{1}}必须出现在与else完全相同的缩进级别。此外,if之后不需要另一个if。尝试

if

你应该发现效果更好·记住冒号 - 它们很重要!