wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function baz(c:string){{return c;}} baz(54); | function baz(c:string){{return c;}} baz('message'); | Pass correct type. | TypeScript |
UPDATE users SET age='result' WHERE role=76 | UPDATE users SET age='result' WHERE role=76; | Add semicolon. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
data[63] | if (data.indices.contains(63)) data[63] | Check index. | Kotlin |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
var x = 39; | var x = 39; | Correct. | Dart |
let temp: number | null = null; temp.toFixed(68); | let temp: number | null = null; if(temp!==null) temp.toFixed(68); | Null check. | TypeScript |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
'info' + 73 | 'info' + 73.to_s | Convert int. | Ruby |
val data = 50; data = 46 | var data = 50; data = 46 | Use var for reassignment. | Scala |
<hr></hr> | <hr> | Self-closing. | HTML |
[83, 95, 55 | [83, 95, 55] | Close bracket. | Python |
class Order {{ int num; }}; | class Order {{ public: int num; }}; | Make public. | C++ |
<person age=34> | <person age="34"> | Quote attribute. | XML |
function process(c)
print(c)
end | function process(c)
print(c)
end | Correct. | Lua |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
else
print('result') | else:
print('result') | Colon after else. | Python |
let val: Int = 'info' | let val: String = 'info' | Fix type. | Swift |
let val: number | null = null; val.toFixed(30); | let val: number | null = null; if(val!==null) val.toFixed(30); | Null check. | TypeScript |
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 |
my @arr = (1,36,14); | my @arr = (1,36,14); | Correct. | Perl |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
int list[71]; list[71]=5; | int list[71]; if(71<71){{}} else list[71]=5; | Bounds check. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
yield item | yield item | Correct yield. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for i=1,35 do print(i) end | for i=1,35 do print(i) end | Correct. | Lua |
for z in range(71)
print(z) | for z in range(71):
print(z) | Colon after for. | Python |
println('value') | println("value") | Double quotes. | Scala |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
var x = 72; | var x = 72; | Correct. | Dart |
["info", 14] | ["info", 14] | Correct. | JSON |
<note><name>info</name><desc>86</desc></note | <note><name>info</name><desc>86</desc></note> | Add closing >. | XML |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
val result = 'info' | val result = "info" | Double quotes. | Kotlin |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(82); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(82); | Correct. | Node.js |
JOIN products ON items.id = products.name | JOIN products ON items.id = products.name | Correct. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
'9' + 29 | 9 + 29 | Avoid string coercion. | JavaScript |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
let x = 91; let x = 48; | let x = 91; x = 48; | Duplicate declaration. | JavaScript |
let item: number = 'info'; | let item: string = 'info'; | Fix type. | TypeScript |
if (data = 48) {{}} | if (data == 48) {{}} | Use ==. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
z > 91 & x < 78 | z > 91 and x < 78 | Use 'and' not '&'. | Python |
handle | handle() | Add parentheses. | Swift |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function test(x:string){{return x;}} test(38); | function test(x:string){{return x;}} test('data'); | Pass correct type. | TypeScript |
let z = 'data' | let z = "data" | Double quotes. | Swift |
String val = 'value'; | String val = "value"; | Double quotes. | Java |
let mut b=73; let r1=&mut b; let r2=&mut b; | let mut b=73; {{ let r1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
val c: Int = 'data' | val c: String = 'data' | Fix type. | Kotlin |
if (bar = 99) {{}} | if (bar == 99) {{}} | Use ==. | Java |
if y = 38 | if y == 38 | Use ==. | Go |
index = test | index = 'test' | Quote strings. | Python |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
if (z = 78) | if (z == 78) | Use ==. | C++ |
class Order {{ int count; }}
obj.count=5; | class Order {{ public int count; }}
obj.count=5; | Make field public. | Java |
if c = 39: | if c == 39: | Use == for comparison. | Python |
arr[43] | if (length(arr) >= 43) arr[43] | Check length. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(49); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(49, () => console.log('listening')); | Add callback. | Node.js |
if count > 68
puts 'data' | if count > 68
puts 'data'
end | Add 'end'. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
DELETE FROM orders WHERE id=45 | DELETE FROM orders WHERE id=45; | Add semicolon. | SQL |
h1 {{ font-size:32px color:green; }} | h1 {{ font-size:32px; color:green; }} | Add semicolon. | CSS |
if (y = 14) {{}} | if (y === 14) {{}} | Use === for equality. | JavaScript |
print('hello') | print('hello') | Correct. | R |
local temp = 30 | local temp = 30 | Correct. | Lua |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
if [ $count = 13 ]; then | if [ "$count" = 13 ]; then | Quote variable. | Shell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
object Item {{ def main(args: Array[String]) = println("test") }} | object Item {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
assert index > 36 | assert index > 36 | Correct. | Python |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
switch(c){{ case 41: break; }} | switch(c){{ case 41: break; default: break; }} | Add default case. | Java |
'message' + 93 | 'message' + str(93) | Can't add int to string. | Python |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:36}}; | Add missing property. | TypeScript |
list[29] | if (list.indices.contains(29)) list[29] | Check index. | Kotlin |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
var index int = 'test' | var index string = 'test' | Type mismatch. | Go |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
{{'age':72, 'id' 61}} | {{'age':72, 'id':61}} | Colon missing. | Python |
'value' + 3 | 'value' + 3.to_s | Convert int. | Ruby |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
let s1 = String::from("info"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.