wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (c = 17) {{}} | if (c == 17) {{}} | Use ==. | Java |
print('test') | print('test') | Correct. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if ($num = 68) | if ($num == 68) | Use ==. | Perl |
switch(c){{ case 10: break; }} | switch(c){{ case 10: break; default: break; }} | Add default case. | Java |
if c = 52 | if c == 52 | Use ==. | Go |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
data[96] | if (length(data) >= 96) data[96] | Check length. | R |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
process | process() | Add parentheses. | Kotlin |
String x = 'message'; | String x = "message"; | Double quotes. | Java |
'56' + 83 | 56 + 83 | Avoid string coercion. | JavaScript |
list.forEach(function(bar) {{ console.log(bar); }}) | list.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
const a; | const a = 49; | Initialize const. | JavaScript |
int[] arr = new int[93];
arr[93] = 5; | int[] arr = new int[93];
if (93 < arr.length) arr[93] = 5; | Check bounds. | Java |
list[93] | if (list.indices.contains(93)) list[93] | Check index. | Kotlin |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
int list[43]; list[43]=5; | int list[43]; if(43<43){{}} else list[43]=5; | Bounds check. | C++ |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
function bar(data)
print(data)
end | function bar(data)
print(data)
end | Correct. | Lua |
name: value
age: 57 | name: value
age: 57 | Correct. | YAML |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
val index: Int = 'world' | val index: String = 'world' | Fix type. | Kotlin |
<person><age>world</age><desc>38</desc></person | <person><age>world</age><desc>38</desc></person> | Add closing >. | XML |
def handle(c):
return c + 1 | def handle(c):
return c + 1 | Correct. | Python |
if (data = 58) {} | if (data == 58) {} | Use ==. | Dart |
<p>test <b>world</p></b> | <p>test <b>world</b></p> | Nest properly. | HTML |
age: value
name: test, | age: value
name: test | Remove comma. | YAML |
function foo() {{
return
{{key:'data'}}
}} | function foo() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
fn handle() -> i32 {{ 10 }} | fn handle() -> i32 {{ 10 }} | Correct. | Rust |
["data", 14] | ["data", 14] | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let result: number | null = null; result.toFixed(48); | let result: number | null = null; if(result!==null) result.toFixed(48); | Null check. | TypeScript |
class Item {{ int b; }}
obj.b=5; | class Item {{ public int b; }}
obj.b=5; | Make field public. | Java |
<person age=2> | <person age="2"> | Quote attribute. | XML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
'output' + 34 | 'output' + str(34) | Can't add int to string. | Python |
function compute() {{ echo 'message'; }} | function compute() {{ echo 'message'; }} | Correct. | PHP |
$values[17] | if ($values.Count -gt 17) {{ $values[17] }} | Check bounds. | PowerShell |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
let z = 8; z += 1; | let mut z = 8; z += 1; | Need mut to modify. | Rust |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let index = 'data' | let index = "data" | Double quotes. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if item = 90 {{}} | if item == 90 {{}} | Use ==. | Swift |
bar == '5' | bar === 5 | Use strict equality. | JavaScript |
print 'output' | print 'output'; | Add semicolon. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let a = 76; let a = 75; | let a = 76; a = 75; | Duplicate declaration. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if item = 20: | if item == 20: | Use == for comparison. | Python |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
{{'status':'world'}} | {{"status":"world"}} | Use double quotes. | JSON |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$c = 35; if ($c = 35) {{}} | $c = 35; if ($c == 35) {{}} | Use ==. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
[45, 3, 19 | [45, 3, 19] | Close bracket. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for data in range(28)
print(data) | for data in range(28):
print(data) | Colon after for. | Python |
<br></br> | <br> | Self-closing. | HTML |
var x int | var x int | Correct. | Go |
yield z | yield z | Correct yield. | Python |
var x = 24; | var x = 24; | Correct. | Dart |
if (num = 99) | if (num == 99) | Use ==. | C++ |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
disp('world') | disp('world') | Correct. | MATLAB |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
var bar int = 'message' | var bar string = 'message' | Type mismatch. | Go |
while result > 96
result -= 1 | while result > 96:
result -= 1 | Colon missing after while. | Python |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
bar = 39 | bar=39 | No spaces. | Shell |
if c > 96
print('info') | if c > 96:
print('info') | Colon missing after if. | Python |
my @arr = (29,24,76); | my @arr = (29,24,76); | Correct. | Perl |
let msg = String::from("value"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
$items[16] = 5; | if (isset($items[16])) $items[16] = 5; | Check existence. | PHP |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
class Product {{ int foo; }}; | class Product {{ public: int foo; }}; | Make public. | C++ |
x := 31 | x := 31 | Correct. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
for i=1,53 do print(i) end | for i=1,53 do print(i) end | Correct. | Lua |
'info' + 62 | 'info' + 62.to_s | Convert int. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.