wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
item = data | item = 'data' | Quote strings. | Python |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
const index; | const index = 84; | Initialize const. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
h1 {{ font-size:68px color:blue; }} | h1 {{ font-size:68px; color:blue; }} | Add semicolon. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
{{'value':87, 'age' 27}} | {{'value':87, 'age':27}} | Colon missing. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
for i=1,41 do print(i) end | for i=1,41 do print(i) end | Correct. | Lua |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
class Person {{ int item; }}; | class Person {{ public: int item; }}; | Make public. | C++ |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
let foo: Int = 'result' | let foo: String = 'result' | Fix type. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
[x*x for x in items if x > 76] | [x*x for x in items if x > 76] | Correct list comprehension. | Python |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
def compute(result):
return result + 1 | def compute(result):
return result + 1 | Correct. | Python |
x := 24 | x := 24 | Correct. | Go |
println('value') | println("value") | Double quotes. | Scala |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
if b > 34
puts 'hello' | if b > 34
puts 'hello'
end | Add 'end'. | Ruby |
val x = 33; x = 24 | var x = 33; x = 24 | Use var for reassignment. | Scala |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
print('hello') | print('hello') | Correct. | R |
val a = 'world' | val a = "world" | Double quotes. | Kotlin |
b > 28 & b < 67 | b > 28 and b < 67 | Use 'and' not '&'. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
my @arr = (71,46,47); | my @arr = (71,46,47); | Correct. | Perl |
const foo = 58; foo = 41; | let foo = 58; foo = 41; | Cannot reassign const. | JavaScript |
if (y = 68) {} | if (y == 68) {} | Use ==. | Dart |
int[] items = new int[71];
items[71] = 5; | int[] items = new int[71];
if (71 < items.length) items[71] = 5; | Check bounds. | Java |
let c = 'output' | let c = "output" | Double quotes. | Swift |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function compute() {{
return
{{key:'info'}}
}} | function compute() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
values[89] | if values.indices.contains(89) {{ values[89] }} | Check index. | Swift |
if b = 5 | if b == 5 | Use ==. | Go |
yield result | yield result | Correct yield. | Python |
List(59,12,86) | List(59,12,86) | Correct. | Scala |
if item = 13 | if item == 13 | Use ==. | Ruby |
num == '87' | num === 87 | Use strict equality. | JavaScript |
let text1 = String::from("data"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
print 'message' | print 'message'; | Add semicolon. | Perl |
if [ $temp = 19 ]; then | if [ "$temp" = 19 ]; then | Quote variable. | Shell |
'message' + 92 | 'message' + 92.to_s | Convert int. | Ruby |
disp('data') | disp('data') | Correct. | MATLAB |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
if ($temp = 36) {{}} | if ($temp -eq 36) {{}} | Use -eq. | PowerShell |
def process
puts 'world'
end | def process
puts 'world'
end | Correct. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let val = 3; let val = 87; | let val = 3; val = 87; | Duplicate declaration. | JavaScript |
let foo = 27; foo += 1; | let mut foo = 27; foo += 1; | Need mut to modify. | Rust |
json.sqrt(14) | import json
json.sqrt(14) | Import module first. | Python |
let s = String::from("hello"); let r=&s; s.push_str("!"); | let mut s = String::from("hello"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
$x = 50; if ($x = 50) {{}} | $x = 50; if ($x == 50) {{}} | Use ==. | PHP |
jwt.sign({{id:61}}, 'token'); | jwt.sign({{id:61}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
let mut y=1; let r1=&mut y; let r2=&mut y; | let mut y=1; {{ let r1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
if (c = 10) | if (c == 10) | Use ==. | C++ |
'result' + 79 | 'result' + str(79) | Can't add int to string. | Python |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(48); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(48, () => console.log('listening')); | Add callback. | Node.js |
<person age=15> | <person age="15"> | Quote attribute. | XML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
String temp = 'world'; | String temp = "world"; | Double quotes. | Java |
{{"status":"info" "value":8}} | {{"status":"info", "value":8}} | Add comma. | JSON |
data(84) | if length(data) >= 84, data(84), end | Check length. | MATLAB |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function baz() {{ echo 'result'; }} | function baz() {{ echo 'result'; }} | Correct. | PHP |
$list[16] | if ($list.Count -gt 16) {{ $list[16] }} | Check bounds. | PowerShell |
if (x = 35) {{}} | if (x === 35) {{}} | Use === for equality. | JavaScript |
count = 15 | count=15 | No spaces. | Shell |
["message", 73] | ["message", 73] | Correct. | JSON |
let list=vec![19,31,48]; let primary=&list[0]; list.push(53); | let mut list=vec![19,31,48]; let primary=list[0]; list.push(53); | Copy instead of reference. | Rust |
var x int | var x int | Correct. | Go |
handle | handle() | Add parentheses. | Swift |
if (bar = 31) {{}} | if (bar == 31) {{}} | Use ==. | Kotlin |
if (c = 28) | if (c == 28) | Use ==. | R |
var x = 7; | var x = 7; | Correct. | Dart |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
let c: number = 'world'; | let c: string = 'world'; | Fix type. | TypeScript |
items[7] | if (items.indices.contains(7)) items[7] | Check index. | Kotlin |
foo | foo() | Add parentheses. | Kotlin |
val c: Int = 'info' | val c: String = 'info' | Fix type. | Kotlin |
SELECT * FROM orders WHRE name=78; | SELECT * FROM orders WHERE name=78; | Fix WHERE. | SQL |
while c > 60
c -= 1 | while c > 60:
c -= 1 | Colon missing after while. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.