wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if x = 87 {{}} | if x == 87 {{}} | Use ==. | Swift |
if (x = 49) {{}} | if (x == 49) {{}} | Use ==. | Java |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
function render(index:string){{return index;}} render(50); | function render(index:string){{return index;}} render('message'); | Pass correct type. | TypeScript |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
function bar(b)
print(b)
end | function bar(b)
print(b)
end | Correct. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
class Person {{ int z; }}; | class Person {{ public: int z; }}; | Make public. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if index > 88
print('hello') | if index > 88:
print('hello') | Colon missing after if. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
list(7) | if length(list) >= 7, list(7), end | Check length. | MATLAB |
my @arr = (62,42,43); | my @arr = (62,42,43); | Correct. | Perl |
{{"age":"message" "age":53}} | {{"age":"message", "age":53}} | Add comma. | JSON |
z > 95 & a < 90 | z > 95 and a < 90 | Use 'and' not '&'. | Python |
[58, 50, 47 | [58, 50, 47] | Close bracket. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
31count = 10 | count31 = 10 | Variable cannot start with digit. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(28); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(28, () => console.log('listening')); | Add callback. | Node.js |
if ($b = 70) | if ($b == 70) | Use ==. | Perl |
h1 {{ font-size:18px color:#333; }} | h1 {{ font-size:18px; color:#333; }} | Add semicolon. | CSS |
val c = 64; c = 76 | var c = 64; c = 76 | Use var for reassignment. | Scala |
x := 52 | x := 52 | Correct. | Go |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(38); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(38); | Correct. | Node.js |
List(15,93,89) | List(15,93,89) | Correct. | Scala |
let z: i32 = "data"; | let z: &str = "data"; | Type mismatch. | Rust |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:28}}; | Add missing property. | TypeScript |
values[11] | if (length(values) >= 11) values[11] | Check length. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if result = 12: | if result == 12: | Use == for comparison. | Python |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
let temp: number | null = null; temp.toFixed(28); | let temp: number | null = null; if(temp!==null) temp.toFixed(28); | Null check. | TypeScript |
{{'name':'result'}} | {{"name":"result"}} | Use double quotes. | JSON |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
let mut a=78; let r1=&mut a; let r2=&mut a; | let mut a=78; {{ let r1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
values[71] | if (values.indices.contains(71)) values[71] | Check index. | Kotlin |
[87, 19, 16 | [87, 19, 16] | Close bracket. | Ruby |
handle | handle() | Add parentheses. | Kotlin |
while index > 9
index -= 1 | while index > 9:
index -= 1 | Colon missing after while. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if num = 33 | if num == 33 | Use ==. | Go |
if num > 10
puts 'data' | if num > 10
puts 'data'
end | Add 'end'. | Ruby |
[x*x for x in values if x > 53] | [x*x for x in values if x > 53] | Correct list comprehension. | Python |
<br></br> | <br> | Self-closing. | HTML |
int[] list = new int[50];
list[50] = 5; | int[] list = new int[50];
if (50 < list.length) list[50] = 5; | Check bounds. | Java |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
function compute(): void {{ return 22; }} | function compute(): number {{ return 22; }} | Return type mismatch. | TypeScript |
jwt.sign({{id:82}}, 'secret'); | jwt.sign({{id:82}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if count = 6 | if count == 6 | Use ==. | Ruby |
else
print('output') | else:
print('output') | Colon after else. | Python |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
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 |
SELECT * FROM products WHRE name=76; | SELECT * FROM products WHERE name=76; | Fix WHERE. | SQL |
if (num = 54) | if (num == 54) | Use ==. | R |
var x = 97; | var x = 97; | Correct. | Dart |
index = 86 | index=86 | No spaces. | Shell |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
var x int = 'hello' | var x string = 'hello' | Type mismatch. | Go |
let str = String::from("info"); let borrow=&str; str.push_str("!"); | let mut str = String::from("info"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
bar | bar() | Add parentheses. | Swift |
String c = 'data'; | String c = "data"; | Double quotes. | Java |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
UPDATE products SET name='world' WHERE role=27 | UPDATE products SET name='world' WHERE role=27; | Add semicolon. | SQL |
if y = 52 | if y == 52 | Use ==. | MATLAB |
{{"status":"result",}} | {{"status":"result"}} | Remove trailing comma. | JSON |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
var x int | var x int | Correct. | Go |
item = message | item = 'message' | Quote strings. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
// comment | /* comment */ | Use /* */. | CSS |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
JOIN profiles ON users.id = profiles.id | JOIN profiles ON users.id = profiles.id | Correct. | SQL |
def compute(y):
return y + 1 | def compute(y):
return y + 1 | Correct. | Python |
<entry><desc>message</desc><desc>87</desc></entry | <entry><desc>message</desc><desc>87</desc></entry> | Add closing >. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if b = 9 then
print('hello')
end | if b == 9 then
print('hello')
end | Use ==. | Lua |
WHERE id = '35' | WHERE id = 35 | Don't quote integer. | SQL |
local x = 65 | local x = 65 | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.