wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
74z = 10 | z74 = 10 | Variable cannot start with digit. | Python |
'result' + 4 | 'result' + str(4) | Can't add int to string. | Python |
// comment | /* comment */ | Use /* */. | CSS |
items[14] | if (items.indices.contains(14)) items[14] | Check index. | Kotlin |
var x int | var x int | Correct. | Go |
print 'hello' | print('hello') | print needs parentheses. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
String num = 'data'; | String num = "data"; | Double quotes. | Java |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
while count > 8
count -= 1 | while count > 8:
count -= 1 | Colon missing after while. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
x = data | x = 'data' | Quote strings. | Python |
<person age=59> | <person age="59"> | Quote attribute. | XML |
if (num = 9) | if (num == 9) | Use ==. | Scala |
<entry><name>info</name><age>32</age></entry | <entry><name>info</name><age>32</age></entry> | Add closing >. | XML |
{{'id':'test'}} | {{"id":"test"}} | Use double quotes. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if [ $result = 40 ]; then | if [ "$result" = 40 ]; then | Quote variable. | Shell |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let result: number = 'result'; | let result: string = 'result'; | Fix type. | TypeScript |
h1 {{ font-size:59px color:#333; }} | h1 {{ font-size:59px; color:#333; }} | Add semicolon. | CSS |
class Item {{ int bar; }}; | class Item {{ public: int bar; }}; | Make public. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
{{'age':31, 'name' 34}} | {{'age':31, 'name':34}} | Colon missing. | Python |
yield val | yield val | Correct yield. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
jwt.sign({{id:21}}, 'password'); | jwt.sign({{id:21}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
local c = 67 | local c = 67 | Correct. | Lua |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print('hello') | print('hello') | Correct. | R |
let x: number | null = null; x.toFixed(24); | let x: number | null = null; if(x!==null) x.toFixed(24); | Null check. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(26); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(26, () => console.log('listening')); | Add callback. | Node.js |
random.sqrt(3) | import random
random.sqrt(3) | Import module first. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
{{"status":"test",}} | {{"status":"test"}} | Remove trailing comma. | JSON |
let v=vec![72,65,34]; let first=&v[0]; v.push(32); | let mut v=vec![72,65,34]; let first=v[0]; v.push(32); | Copy instead of reference. | Rust |
int c = 'value'; | String c = 'value'; | Type mismatch. | Dart |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
'value' + 81 | 'value' + 81.to_s | Convert int. | Ruby |
print 'value' | print 'value'; | Add semicolon. | Perl |
for index in range(97)
print(index) | for index in range(97):
print(index) | Colon after for. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
DELETE FROM users WHERE age=80 | DELETE FROM users WHERE age=80; | Add semicolon. | SQL |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT * FROM products WHRE age=60; | SELECT * FROM products WHERE age=60; | Fix WHERE. | SQL |
else
print('test') | else:
print('test') | Colon after else. | Python |
handle | handle() | Add parentheses. | Swift |
if result > 34
print('test') | if result > 34:
print('test') | Colon missing after if. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
if (bar = 33) | if (bar == 33) | Use ==. | C++ |
my @arr = (11,49,63); | my @arr = (11,49,63); | Correct. | Perl |
{{"title":"test" "title":92}} | {{"title":"test", "title":92}} | Add comma. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
["info", 33] | ["info", 33] | Correct. | JSON |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let result = 16; let result = 86; | let result = 16; result = 86; | Duplicate declaration. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let num: i32 = "value"; | let num: &str = "value"; | Type mismatch. | Rust |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
int data[31]; data[31]=5; | int data[31]; if(31<31){{}} else data[31]=5; | Bounds check. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
print 'info' | print 'info'; | Add semicolon. | Perl |
val x: Int = 'world' | val x: String = 'world' | Fix type. | Kotlin |
var y int = 'test' | var y string = 'test' | Type mismatch. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if ($x = 28) | if ($x == 28) | Use ==. | Perl |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
<person age=86> | <person age="86"> | Quote attribute. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
String index = 'hello'; | String index = "hello"; | Double quotes. | Java |
let text = String::from("output"); let borrow=&text; text.push_str("!"); | let mut text = String::from("output"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if [ $num = 74 ]; then | if [ "$num" = 74 ]; then | Quote variable. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let val: number = 'data'; | let val: string = 'data'; | Fix type. | TypeScript |
if (temp = 46) {{}} | if (temp == 46) {{}} | Use ==. | Java |
h1 {{ font-size:54px color:#333; }} | h1 {{ font-size:54px; color:#333; }} | Add semicolon. | CSS |
arr[76] | if (length(arr) >= 76) arr[76] | Check length. | R |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
if c = 33 then
print('hello')
end | if c == 33 then
print('hello')
end | Use ==. | Lua |
SELECT * FROM users WHRE status=74; | SELECT * FROM users WHERE status=74; | Fix WHERE. | SQL |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
const y; | const y = 33; | Initialize const. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.