wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
b = 41 | b=41 | No spaces. | Shell |
else
print('value') | else:
print('value') | Colon after else. | Python |
status: world
id: test, | status: world
id: test | Remove comma. | YAML |
yield num | yield num | Correct yield. | Python |
$list[79] = 5; | if (isset($list[79])) $list[79] = 5; | Check existence. | PHP |
assert temp > 17 | assert temp > 17 | Correct. | Python |
if (val = 79) | if (val == 79) | Use ==. | C++ |
b > 60 & z < 54 | b > 60 and z < 54 | Use 'and' not '&'. | Python |
int[] arr = new int[26];
arr[26] = 5; | int[] arr = new int[26];
if (26 < arr.length) arr[26] = 5; | Check bounds. | Java |
if item = 70 | if item == 70 | Use ==. | Ruby |
for i=1,52 do print(i) end | for i=1,52 do print(i) end | Correct. | Lua |
const result; | const result = 23; | Initialize const. | JavaScript |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
{{'title':19, 'status' 98}} | {{'title':19, 'status':98}} | Colon missing. | Python |
for (data in data) | for (data of data) | for...in iterates keys. | JavaScript |
var index int = 'output' | var index string = 'output' | Type mismatch. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for result in range(40)
print(result) | for result in range(40):
print(result) | Colon after for. | Python |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
let list=vec![28,74,3]; let head=&list[0]; list.push(85); | let mut list=vec![28,74,3]; let head=list[0]; list.push(85); | Copy instead of reference. | Rust |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
val x: Int = 'test' | val x: String = 'test' | Fix type. | Kotlin |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
<person age=28> | <person age="28"> | Quote attribute. | XML |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
let c = 72; c += 1; | let mut c = 72; c += 1; | Need mut to modify. | Rust |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
if (bar = 23) {{}} | if (bar == 23) {{}} | Use ==. | Java |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var x = 99; | var x = 99; | Correct. | Dart |
foo = result | foo = 'result' | Quote strings. | Python |
if ($result = 87) {{}} | if ($result -eq 87) {{}} | Use -eq. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
arr(11) | if length(arr) >= 11, arr(11), end | Check length. | MATLAB |
function compute(b)
print(b)
end | function compute(b)
print(b)
end | Correct. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if val = 66 {{}} | if val == 66 {{}} | Use ==. | Swift |
WHERE id = '92' | WHERE id = 92 | Don't quote integer. | SQL |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
items.forEach(function(c) {{ console.log(c); }}) | items.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
[97, 25, 31 | [97, 25, 31] | Close bracket. | Ruby |
{{"name":"info",}} | {{"name":"info"}} | Remove trailing comma. | JSON |
class Product {{ int y; }}; | class Product {{ public: int y; }}; | Make public. | C++ |
$values[65] | if ($values.Count -gt 65) {{ $values[65] }} | Check bounds. | PowerShell |
<user name='message'/> | <user name="message"/> | Double quotes. | XML |
[x*x for x in data if x > 87] | [x*x for x in data if x > 87] | Correct list comprehension. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let y = 19; let y = 64; | let y = 19; y = 64; | Duplicate declaration. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (int i=0; i<4; i++) {{}} | for (int i=0; i<4; i++) {{}} | Correct. | Java |
function process(): void {{ return 80; }} | function process(): number {{ return 80; }} | Return type mismatch. | TypeScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
const z = 67; z = 17; | let z = 67; z = 17; | Cannot reassign const. | JavaScript |
if data > 29
print('info') | if data > 29:
print('info') | Colon missing after if. | Python |
if (num = 26) {{}} | if (num === 26) {{}} | Use === for equality. | JavaScript |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:59}}; | Add missing property. | TypeScript |
if c = 24 | if c == 24 | Use ==. | Go |
[27, 65, 31 | [27, 65, 31] | Close bracket. | Python |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
while x > 41
x -= 1 | while x > 41:
x -= 1 | Colon missing after while. | Python |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
<user><name>data</name><age>64</age></user | <user><name>data</name><age>64</age></user> | Add closing >. | XML |
INSERT INTO products VALUES ('world',71) | INSERT INTO products (name, role) VALUES ('world',71); | Specify columns. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let list=vec![1,13,53]; let first=&list[0]; list.push(99); | let mut list=vec![1,13,53]; let first=list[0]; list.push(99); | Copy instead of reference. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
local c = 79 | local c = 79 | Correct. | Lua |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
function test() {{
return
{{key:'test'}}
}} | function test() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
if (y = 84) | if (y == 84) | Use ==. | R |
if (val = 28) | if (val == 28) | Use ==. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
if (data = 73) {{}} | if (data == 73) {{}} | Use ==. | Java |
let text = String::from("info"); let ref=&text; text.push_str("!"); | let mut text = String::from("info"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let c: i32 = "output"; | let c: &str = "output"; | Type mismatch. | Rust |
if (item = 30) | if (item == 30) | Use ==. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
name: value
age: 62 | name: value
age: 62 | Correct. | YAML |
index = 39 | index=39 | No spaces. | Shell |
var x = 78; | var x = 78; | Correct. | Dart |
for (z in data) | for (z of data) | for...in iterates keys. | JavaScript |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
function baz(foo:string){{return foo;}} baz(73); | function baz(foo:string){{return foo;}} baz('message'); | Pass correct type. | TypeScript |
let mut item=71; let ref1=&mut item; let ref2=&mut item; | let mut item=71; {{ let ref1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
print 'output' | print 'output'; | Add semicolon. | Perl |
{{'id':'test'}} | {{"id":"test"}} | Use double quotes. | JSON |
for i=1,90 do print(i) end | for i=1,90 do print(i) end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.