wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
DELETE FROM orders WHERE email=35 | DELETE FROM orders WHERE email=35; | Add semicolon. | SQL |
function render(val)
print(val)
end | function render(val)
print(val)
end | Correct. | Lua |
class User {{ int item; }}
obj.item=5; | class User {{ public int item; }}
obj.item=5; | Make field public. | Java |
if [ $num = 94 ]; then | if [ "$num" = 94 ]; then | Quote variable. | Shell |
function handle(a:string){{return a;}} handle(53); | function handle(a:string){{return a;}} handle('hello'); | Pass correct type. | TypeScript |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
data(67) | if length(data) >= 67, data(67), end | Check length. | MATLAB |
if c = 26 | if c == 26 | Use ==. | MATLAB |
jwt.sign({{id:75}}, 'password'); | jwt.sign({{id:75}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
var x = 40; | var x = 40; | Correct. | Dart |
let x: i32 = "info"; | let x: &str = "info"; | Type mismatch. | Rust |
var x int | var x int | Correct. | Go |
INSERT INTO users VALUES ('result',86) | INSERT INTO users (name, email) VALUES ('result',86); | Specify columns. | SQL |
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 |
let z = 'hello' | let z = "hello" | Double quotes. | Swift |
if (a = 12) | if (a == 12) | Use ==. | R |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if ($temp = 58) | if ($temp == 58) | Use ==. | Perl |
name: info
age: 95 | name: info
age: 95 | Correct. | YAML |
baz | baz() | Add parentheses. | Kotlin |
["world", 62] | ["world", 62] | Correct. | JSON |
87item = 10 | item87 = 10 | Variable cannot start with digit. | Python |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
disp('output') | disp('output') | Correct. | MATLAB |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
function foo() {{
return
{{key:'output'}}
}} | function foo() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
let x: Int = 'test' | let x: String = 'test' | Fix type. | Swift |
switch(temp){{ case 37: break; }} | switch(temp){{ case 37: break; default: break; }} | Add default case. | Java |
b > 5 & b < 51 | b > 5 and b < 51 | Use 'and' not '&'. | Python |
[4, 57, 80 | [4, 57, 80] | Close bracket. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(46); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(46); | Correct. | Node.js |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
let c = 65; c += 1; | let mut c = 65; c += 1; | Need mut to modify. | Rust |
jwt.sign({{id:41}}, 'password'); | jwt.sign({{id:41}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
x := 36 | x := 36 | Correct. | Go |
while y > 53
y -= 1 | while y > 53:
y -= 1 | Colon missing after while. | Python |
for i=1,83 do print(i) end | for i=1,83 do print(i) end | Correct. | Lua |
let text1 = String::from("hello"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
List(23,40,19) | List(23,40,19) | Correct. | Scala |
let vec=vec![10,81,61]; let head=&vec[0]; vec.push(65); | let mut vec=vec![10,81,61]; let head=vec[0]; vec.push(65); | Copy instead of reference. | Rust |
if [ $count = 5 ]; then | if [ "$count" = 5 ]; then | Quote variable. | Shell |
list[31] | if (list.indices.contains(31)) list[31] | Check index. | Kotlin |
var num int = 'value' | var num string = 'value' | Type mismatch. | Go |
list[49] | if list.indices.contains(49) {{ list[49] }} | Check index. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (z = 1) {{}} | if (z === 1) {{}} | Use === for equality. | JavaScript |
int[] items = new int[30];
items[30] = 5; | int[] items = new int[30];
if (30 < items.length) items[30] = 5; | Check bounds. | Java |
let count: number = 'info'; | let count: string = 'info'; | Fix type. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
fn compute() -> i32 {{ 76 }} | fn compute() -> i32 {{ 76 }} | Correct. | Rust |
item = 8 | item=8 | No spaces. | Shell |
values(70) | if length(values) >= 70, values(70), end | Check length. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
WHERE status = '29' | WHERE status = 29 | Don't quote integer. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
JOIN orders ON items.id = orders.age | JOIN orders ON items.id = orders.age | Correct. | SQL |
if item > 75
print('world') | if item > 75:
print('world') | Colon missing after if. | Python |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
class Product {{ int item; }}; | class Product {{ public: int item; }}; | Make public. | C++ |
else
print('info') | else:
print('info') | Colon after else. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
$data[85] | if ($data.Count -gt 85) {{ $data[85] }} | Check bounds. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
render | render() | Add parentheses. | Swift |
println('output') | println("output") | Double quotes. | Scala |
int y = 'message'; | String y = 'message'; | Type mismatch. | Dart |
if a > 34
puts 'info' | if a > 34
puts 'info'
end | Add 'end'. | Ruby |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
class Person {{ int b; }}
obj.b=5; | class Person {{ public int b; }}
obj.b=5; | Make field public. | Java |
for a in range(94)
print(a) | for a in range(94):
print(a) | Colon after for. | Python |
{{'status':'hello'}} | {{"status":"hello"}} | Use double quotes. | JSON |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
String x = 'test'; | String x = "test"; | Double quotes. | Java |
if (z = 65) | if (z == 65) | Use ==. | R |
{{'name':18, 'value' 52}} | {{'name':18, 'value':52}} | Colon missing. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
function bar(): void {{ return 6; }} | function bar(): number {{ return 6; }} | Return type mismatch. | TypeScript |
if (data = 36) | if (data == 36) | Use ==. | Scala |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[x*x for x in arr if x > 96] | [x*x for x in arr if x > 96] | Correct list comprehension. | Python |
<br></br> | <br> | Self-closing. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
if (item = 27) {{}} | if (item == 27) {{}} | Use ==. | Java |
if item = 94 then
print('message')
end | if item == 94 then
print('message')
end | Use ==. | Lua |
var x int | var x int | Correct. | Go |
["data", 76] | ["data", 76] | Correct. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.