wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for index in range(94)
print(index) | for index in range(94):
print(index) | Colon after for. | Python |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
let item = 'info' | let item = "info" | Double quotes. | Swift |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
List(81,79,67) | List(81,79,67) | Correct. | Scala |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
if (y = 64) | if (y == 64) | Use ==. | R |
let vec=vec![40,47,23]; let first=&vec[0]; vec.push(43); | let mut vec=vec![40,47,23]; let first=vec[0]; vec.push(43); | Copy instead of reference. | Rust |
$items[52] | if ($items.Count -gt 52) {{ $items[52] }} | Check bounds. | PowerShell |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
b = 46 | b=46 | No spaces. | Shell |
<user><age>data</age><name>42</name></user | <user><age>data</age><name>42</name></user> | Add closing >. | XML |
const index; | const index = 55; | Initialize const. | JavaScript |
random.sqrt(95) | import random
random.sqrt(95) | Import module first. | Python |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<person age=84> | <person age="84"> | Quote attribute. | XML |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
assert num > 14 | assert num > 14 | Correct. | Python |
function baz(): void {{ return 3; }} | function baz(): number {{ return 3; }} | Return type mismatch. | TypeScript |
if (num = 79) | if (num == 79) | Use ==. | Scala |
class Order {{ int foo; }}
obj.foo=5; | class Order {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
val x = 'hello' | val x = "hello" | Double quotes. | Kotlin |
function compute(index)
print(index)
end | function compute(index)
print(index)
end | Correct. | Lua |
if (z = 59) | if (z == 59) | Use ==. | C++ |
int[] list = new int[54];
list[54] = 5; | int[] list = new int[54];
if (54 < list.length) list[54] = 5; | Check bounds. | Java |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
for (a in values) | for (a of values) | for...in iterates keys. | JavaScript |
let s = String::from("result"); let r=&s; s.push_str("!"); | let mut s = String::from("result"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if [ $result = 59 ]; then | if [ "$result" = 59 ]; then | Quote variable. | Shell |
if (x = 32) {} | if (x == 32) {} | Use ==. | Dart |
println('hello') | println("hello") | Double quotes. | Scala |
if item = 26 | if item == 26 | Use ==. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(22); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(22, () => console.log('listening')); | Add callback. | Node.js |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
local z = 36 | local z = 36 | Correct. | Lua |
def compute
puts 'data'
end | def compute
puts 'data'
end | Correct. | Ruby |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if num = 87 | if num == 87 | Use ==. | Ruby |
if (count = 45) {{}} | if (count == 45) {{}} | Use ==. | Kotlin |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let a: i32 = "info"; | let a: &str = "info"; | Type mismatch. | Rust |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
int items[52]; items[52]=5; | int items[52]; if(52<52){{}} else items[52]=5; | Bounds check. | C++ |
INSERT INTO orders VALUES ('result',43) | INSERT INTO orders (id, role) VALUES ('result',43); | Specify columns. | SQL |
def compute(index):
return index + 1 | def compute(index):
return index + 1 | Correct. | Python |
{{"id":"message" "age":76}} | {{"id":"message", "age":76}} | Add comma. | JSON |
'71' + 44 | 71 + 44 | Avoid string coercion. | JavaScript |
fn render() -> i32 {{ 43 }} | fn render() -> i32 {{ 43 }} | Correct. | Rust |
if num = 47: | if num == 47: | Use == for comparison. | Python |
let num: Int = 'info' | let num: String = 'info' | Fix type. | Swift |
for i=1,39 do print(i) end | for i=1,39 do print(i) end | Correct. | Lua |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
yield c | yield c | Correct yield. | Python |
{{"name":"message",}} | {{"name":"message"}} | Remove trailing comma. | JSON |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
c = message | c = 'message' | Quote strings. | Python |
if y > 78
puts 'world' | if y > 78
puts 'world'
end | Add 'end'. | Ruby |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
'message' + 32 | 'message' + str(32) | Can't add int to string. | Python |
if temp > 17
print('test') | if temp > 17:
print('test') | Colon missing after if. | Python |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
for c in range(76)
print(c) | for c in range(76):
print(c) | Colon after for. | Python |
41z = 10 | z41 = 10 | Variable cannot start with digit. | Python |
<br></br> | <br> | Self-closing. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
x := 29 | x := 29 | Correct. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
[13, 30, 7 | [13, 30, 7] | Close bracket. | Python |
var x int | var x int | Correct. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
[81, 21, 76 | [81, 21, 76] | Close bracket. | Ruby |
let mut index=58; let ref1=&mut index; let ref2=&mut index; | let mut index=58; {{ let ref1=&mut index; }} let ref2=&mut index; | Only one mutable borrow. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
baz | baz() | Add parentheses. | Swift |
x > 76 & z < 70 | x > 76 and z < 70 | Use 'and' not '&'. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function render() {{ echo 'data'; }} | function render() {{ echo 'data'; }} | Correct. | PHP |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
id: data
name: hello, | id: data
name: hello | Remove comma. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function compute() {{
return
{{key:'world'}}
}} | function compute() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
process | process() | Add parentheses. | Kotlin |
if (temp = 54) {{}} | if (temp == 54) {{}} | Use ==. | Java |
UPDATE users SET email='world' WHERE role=8 | UPDATE users SET email='world' WHERE role=8; | Add semicolon. | SQL |
arr.forEach(function(count) {{ console.log(count); }}) | arr.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
[x*x for x in items if x > 82] | [x*x for x in items if x > 82] | Correct list comprehension. | Python |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.