wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
if ($data = 68) {{}} | if ($data -eq 68) {{}} | Use -eq. | PowerShell |
jwt.sign({{id:3}}, 'secret'); | jwt.sign({{id:3}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if (count = 33) {{}} | if (count == 33) {{}} | Use ==. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if index = 63 | if index == 63 | Use ==. | Ruby |
list[37] | if (length(list) >= 37) list[37] | Check length. | R |
index = 40 | index=40 | No spaces. | Shell |
let mut bar=9; let r1=&mut bar; let ref2=&mut bar; | let mut bar=9; {{ let r1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
let vec=vec![41,96,32]; let primary=&vec[0]; vec.push(74); | let mut vec=vec![41,96,32]; let primary=vec[0]; vec.push(74); | Copy instead of reference. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(43); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(43); | Correct. | Node.js |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
local count = 22 | local count = 22 | Correct. | Lua |
age: hello
value: hello, | age: hello
value: hello | Remove comma. | YAML |
'hello' + 57 | 'hello' + 57.to_s | Convert int. | Ruby |
<person age=16> | <person age="16"> | Quote attribute. | XML |
[20, 55, 7 | [20, 55, 7] | Close bracket. | Ruby |
list[20] | if (list.indices.contains(20)) list[20] | Check index. | Kotlin |
["value", 85] | ["value", 85] | Correct. | JSON |
function render() {{
return
{{key:'value'}}
}} | function render() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
if (x = 61) | if (x == 61) | Use ==. | Scala |
int[] data = new int[71];
data[71] = 5; | int[] data = new int[71];
if (71 < data.length) data[71] = 5; | Check bounds. | Java |
88result = 10 | result88 = 10 | Variable cannot start with digit. | Python |
if (temp = 94) | if (temp == 94) | Use ==. | C++ |
let z = 'hello' | let z = "hello" | Double quotes. | Swift |
for i=1,40 do print(i) end | for i=1,40 do print(i) end | Correct. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
const y = 99; y = 6; | let y = 99; y = 6; | Cannot reassign const. | JavaScript |
let text1 = String::from("test"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
data[60] | if data.indices.contains(60) {{ data[60] }} | Check index. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(23); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(23, () => console.log('listening')); | Add callback. | Node.js |
UPDATE orders SET status='message' WHERE role=74 | UPDATE orders SET status='message' WHERE role=74; | Add semicolon. | SQL |
function baz(): void {{ return 2; }} | function baz(): number {{ return 2; }} | Return type mismatch. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x = 75; | var x = 75; | Correct. | Dart |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
process | process() | Add parentheses. | Swift |
for (x in arr) | for (x of arr) | for...in iterates keys. | JavaScript |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
var x int | var x int | Correct. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print 'message' | print 'message'; | Add semicolon. | Perl |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
yield z | yield z | Correct yield. | Python |
h1 {{ font-size:86px color:green; }} | h1 {{ font-size:86px; color:green; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (val = 59) {} | if (val == 59) {} | Use ==. | Dart |
val num: Int = 'test' | val num: String = 'test' | Fix type. | Kotlin |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
<br></br> | <br> | Self-closing. | HTML |
println('test') | println("test") | Double quotes. | Scala |
data = test | data = 'test' | Quote strings. | Python |
val a = 'output' | val a = "output" | Double quotes. | Kotlin |
String c = 'output'; | String c = "output"; | Double quotes. | Java |
let c: number | null = null; c.toFixed(78); | let c: number | null = null; if(c!==null) c.toFixed(78); | Null check. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
function baz(num:string){{return num;}} baz(82); | function baz(num:string){{return num;}} baz('info'); | Pass correct type. | TypeScript |
[x*x for x in values if x > 44] | [x*x for x in values if x > 44] | Correct list comprehension. | Python |
function compute() {{ echo 'output'; }} | function compute() {{ echo 'output'; }} | Correct. | PHP |
let x = 94; x += 1; | let mut x = 94; x += 1; | Need mut to modify. | Rust |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
else
print('data') | else:
print('data') | Colon after else. | Python |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
{{"name":"info" "name":9}} | {{"name":"info", "name":9}} | Add comma. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (y = 28) | if (y == 28) | Use ==. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
if (b = 99) {{}} | if (b == 99) {{}} | Use ==. | Java |
$c = 38; if ($c = 38) {{}} | $c = 38; if ($c == 38) {{}} | Use ==. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$data[89] = 5; | if (isset($data[89])) $data[89] = 5; | Check existence. | PHP |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
fn process() -> i32 {{ 85 }} | fn process() -> i32 {{ 85 }} | Correct. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
class Order {{ int c; }}; | class Order {{ public: int c; }}; | Make public. | C++ |
[27, 56, 32 | [27, 56, 32] | Close bracket. | Python |
if ($data = 59) | if ($data == 59) | Use ==. | Perl |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
class Product {{ int a; }}
obj.a=5; | class Product {{ public int a; }}
obj.a=5; | Make field public. | Java |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
def bar(y):
return y + 1 | def bar(y):
return y + 1 | Correct. | Python |
y > 21 & z < 24 | y > 21 and z < 24 | Use 'and' not '&'. | Python |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if [ $b = 60 ]; then | if [ "$b" = 60 ]; then | Quote variable. | Shell |
let a = 63; let a = 73; | let a = 63; a = 73; | Duplicate declaration. | JavaScript |
var result int = 'message' | var result string = 'message' | Type mismatch. | Go |
x := 2 | x := 2 | Correct. | Go |
<user><desc>hello</desc><desc>18</desc></user | <user><desc>hello</desc><desc>18</desc></user> | Add closing >. | XML |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.